Splittable

Trait Splittable 

Source
pub trait Splittable: Sized {
    // Required method
    fn split_if(&mut self, max: usize) -> Option<Self>;
}
Expand description

Trait for buffer types that may be split at a maximum length.

This is enabled via the cleaver feature.

Required Methods§

Source

fn split_if(&mut self, max: usize) -> Option<Self>

Split if larger than a maximum length.

If self has length greater than the specified maximum, split it into two, returning the new leading segment and with self mutated to contain the remainder.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Splittable for Bytes

This implementation is inexpensive, relying on Bytes::split_to which does not copy.

Source§

fn split_if(&mut self, max: usize) -> Option<Self>

Implementors§