pub mod io;
pub use io::*;
pub use buffer::{
buffered_reader, buffered_writer, copy_buffered, read_chunks, write_chunks, ChunkStream,
DEFAULT_BUFFER_SIZE, LARGE_BUFFER_SIZE, SMALL_BUFFER_SIZE,
};
pub use serialize::{
from_bincode, from_json, read_bincode_file, read_json_file, to_bincode, to_json,
to_json_pretty, write_bincode_file, write_json_file,
};
pub use stream::{stream_read_file, stream_write_file, StreamReader, StreamWriter};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn component_loads() {
let _ = PayloadKind::EngramBincode;
let _ = CompressionCodec::None;
let opts = BinaryWriteOptions::default();
assert_eq!(opts.codec, CompressionCodec::None);
}
#[test]
fn test_serialization_integration() {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct TestData {
id: u32,
name: String,
}
let data = TestData {
id: 123,
name: "test".to_string(),
};
let bytes = to_bincode(&data).unwrap();
let decoded: TestData = from_bincode(&bytes).unwrap();
assert_eq!(data, decoded);
let json = to_json(&data).unwrap();
let decoded: TestData = from_json(&json).unwrap();
assert_eq!(data.id, decoded.id);
}
#[test]
fn test_envelope_integration() {
let data = b"Test data for envelope";
let opts = BinaryWriteOptions::default();
let wrapped = wrap_or_legacy(PayloadKind::EngramBincode, opts, data).unwrap();
let unwrapped = unwrap_auto(PayloadKind::EngramBincode, &wrapped).unwrap();
assert_eq!(data, unwrapped.as_slice());
}
}