pub enum AnyCodec {
Json(JsonCodec),
SimdJson(SimdJsonCodec),
MsgPack(MsgPackCodec),
}Expand description
Enum wrapper for all codec types
This provides a unified type for codec selection without requiring dyn trait objects (which aren’t compatible with generic methods).
Variants§
Json(JsonCodec)
Standard JSON codec
SimdJson(SimdJsonCodec)
Available on crate feature
simd only.SIMD-accelerated JSON codec
MsgPack(MsgPackCodec)
Available on crate feature
msgpack only.MessagePack binary codec
Implementations§
Source§impl AnyCodec
impl AnyCodec
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Create a codec by name
Supported names:
"json"- Standard JSON codec"simd"or"simd-json"- SIMD-accelerated JSON (requiressimdfeature)"msgpack"- MessagePack binary (requiresmsgpackfeature)
Sourcepub fn available_names() -> &'static [&'static str]
pub fn available_names() -> &'static [&'static str]
List available codec names
Sourcepub fn decode<T: DeserializeOwned>(&self, bytes: &[u8]) -> CodecResult<T>
pub fn decode<T: DeserializeOwned>(&self, bytes: &[u8]) -> CodecResult<T>
Decode bytes to a value
Sourcepub fn content_type(&self) -> &'static str
pub fn content_type(&self) -> &'static str
Get the content type
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnyCodec
impl RefUnwindSafe for AnyCodec
impl Send for AnyCodec
impl Sync for AnyCodec
impl Unpin for AnyCodec
impl UnsafeUnpin for AnyCodec
impl UnwindSafe for AnyCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more