#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "alloc")]
extern crate alloc;
pub mod constants;
pub mod engine;
pub mod error;
pub mod parser;
pub mod pull;
pub mod serializer;
pub use babbel_core::Value;
pub use constants::*;
pub use engine::MsgPackEngine;
pub use error::MsgPackError;
pub use parser::{Decoder, DecoderConfig, from_bytes};
pub use pull::{MsgPackPullEvent, MsgPackPullParser};
pub use serializer::{
MsgPackTimestamp, decode_timestamp, encode_timestamp, serialize_to_dest, to_vec,
};
#[inline]
pub fn from_slice(bytes: &[u8]) -> Result<Value, MsgPackError> {
from_bytes(bytes)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_msgpack_timestamp_32_64_96_roundtrip() {
let ts32 = MsgPackTimestamp::new(1_700_000_000, 0);
let b32 = encode_timestamp(ts32);
assert_eq!(b32.len(), 6);
assert_eq!(decode_timestamp(&b32).unwrap(), ts32);
let ts64 = MsgPackTimestamp::new(1_700_000_000, 500_000_000);
let b64 = encode_timestamp(ts64);
assert_eq!(b64.len(), 10);
assert_eq!(decode_timestamp(&b64).unwrap(), ts64);
let ts96 = MsgPackTimestamp::new(-86_400, 123_456_789);
let b96 = encode_timestamp(ts96);
assert_eq!(b96.len(), 15);
assert_eq!(decode_timestamp(&b96).unwrap(), ts96);
}
}