pub struct Flattrs { /* private fields */ }Expand description
Flat attribute storage for message headers.
Uses a single contiguous buffer with inline entry lengths.
Each entry is [key_hash: u64][len: u32][value: bytes].
Linear scan is used for lookup, which is optimal for small N.
Implementations§
Source§impl Flattrs
impl Flattrs
Sourcepub fn to_part(&self) -> Part
pub fn to_part(&self) -> Part
Convert to wire format for transmission.
Returns a Part for zero-copy serialization through the multipart codec.
Sourcepub fn set<T: Serialize>(&mut self, key: Key<T>, value: T)
pub fn set<T: Serialize>(&mut self, key: Key<T>, value: T)
Serialize a value and store it.
If the key already exists:
- Same size value: overwrite in place (no shifting)
- Different size: remove old entry and append new one
Sourcepub fn get<T: AttrValue + DeserializeOwned>(&self, key: Key<T>) -> Option<T>
pub fn get<T: AttrValue + DeserializeOwned>(&self, key: Key<T>) -> Option<T>
Get a value, deserializing from the buffer.
Uses linear search which is optimal for the typical small number of headers (2-5 entries).
Sourcepub fn contains_key<T>(&self, key: Key<T>) -> bool
pub fn contains_key<T>(&self, key: Key<T>) -> bool
Check if a key exists.
Sourcepub fn from_attrs(attrs: &Attrs) -> Self
pub fn from_attrs(attrs: &Attrs) -> Self
Convert from an existing Attrs by serializing all values.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Flattrs
impl<'de> Deserialize<'de> for Flattrs
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Flattrs
impl RefUnwindSafe for Flattrs
impl Send for Flattrs
impl Sync for Flattrs
impl Unpin for Flattrs
impl UnwindSafe for Flattrs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more