pub enum SharedFrame {
Owned(Vec<u8>),
Shared(Arc<Vec<u8>>),
}Expand description
A raw-bytes frame that may be shared (zero-copy) or exclusively owned.
Adjacent nodes that produce and consume the same format can pass a
SharedFrame::Shared variant through the graph; the receiving node reads
the bytes via SharedFrame::as_bytes without any memcpy. When a node
must mutate the payload it calls SharedFrame::into_owned, which clones
the bytes only when there is more than one live Arc reference.
Variants§
Owned(Vec<u8>)
Exclusively-owned byte buffer.
Reference-counted (shared) byte buffer — zero-copy on the read path.
Implementations§
Sourcepub fn into_owned(self) -> Vec<u8> ⓘ
pub fn into_owned(self) -> Vec<u8> ⓘ
Consume into an exclusively-owned Vec<u8>.
Owned— free, no allocation.Sharedwith a unique reference — moves the innerVecout of theArcwithout copying.Sharedwith multiple references — clones the bytes once.
Return an Arc<Vec<u8>> that points at the same allocation as self.
Shared— clones theArc(O(1), no heap allocation).Owned— wraps the buffer in a newArc(one allocation, O(1)).
Sourcepub fn promote(self) -> Self
pub fn promote(self) -> Self
Promote an Owned frame to Shared, consuming self.
If already Shared, returns self unchanged.
Returns true if this is the Shared variant.
Trait Implementations§
Source§fn clone(&self) -> SharedFrame
fn clone(&self) -> SharedFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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