pub enum SplitPolicy {
Shared,
Owned,
}Expand description
Controls how Bytes::split behaves when the allocation can’t be split in place.
Variants§
Prefer zero-copy splits, allowing the allocation to be shared behind an
Arc when it can’t be split natively.
Mutating a resulting half then triggers a copy-on-write. This is the best choice for read-only or clone-heavy use cases, where the extra copy is never paid.
Owned
Ensure both halves are independently owned, copying eagerly when a native split isn’t possible.
This avoids a later copy-on-write surprise when the halves will be mutated. Prefer it when you split in order to mutate, so the copy is paid once, up front, instead of lazily on first write.
Trait Implementations§
Source§impl Clone for SplitPolicy
impl Clone for SplitPolicy
Source§fn clone(&self) -> SplitPolicy
fn clone(&self) -> SplitPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SplitPolicy
Source§impl Debug for SplitPolicy
impl Debug for SplitPolicy
impl Eq for SplitPolicy
Source§impl PartialEq for SplitPolicy
impl PartialEq for SplitPolicy
impl StructuralPartialEq for SplitPolicy
Auto Trait Implementations§
impl Freeze for SplitPolicy
impl RefUnwindSafe for SplitPolicy
impl Send for SplitPolicy
impl Sync for SplitPolicy
impl Unpin for SplitPolicy
impl UnsafeUnpin for SplitPolicy
impl UnwindSafe for SplitPolicy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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