1 package com.github.davidmoten.rx2.buffertofile;
2
3 import java.io.DataInput;
4 import java.io.DataOutput;
5 import java.io.IOException;
6
7 public interface DataSerializer<T> {
8
9 void serialize(T t, DataOutput out) throws IOException;
10
11 T deserialize(DataInput in) throws IOException;
12
13 /**
14 * Returns 0 to indicate unknown (unbounded) capacity. Otherwise returns a
15 * value that will be used to size internal byte arrays to receive the
16 * serialized bytes ready for deserialization. An appropriate sizeHint will
17 * reduce array copying (like in `ByteArrayOutputStream`) to improve
18 * performance.
19 *
20 * @return size hint to avoid byte array copying.
21 */
22 int sizeHint();
23 }