Skip to main content

OwnedBytes

Trait OwnedBytes 

Source
pub trait OwnedBytes: Sized + 'static {
    // Required method
    fn from_bytes(bytes: Bytes) -> Self;

    // Provided method
    fn claim<V: Any>(view: V) -> Result<Self, V> { ... }
}
Expand description

An owned byte container a decoded field can be built in.

Every container can be built from shared Bytes. A container that is the storage type of a Buf also claims the views that buffer offers, so a field of that type decodes as a view of the input.

Required Methods§

Source

fn from_bytes(bytes: Bytes) -> Self

Builds the container from shared bytes.

Provided Methods§

Source

fn claim<V: Any>(view: V) -> Result<Self, V>

Claims a view a buffer offers in its own storage type, or returns it unchanged.

A container claims exactly the views of its own type unless it overrides this.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl OwnedBytes for Bytes

Source§

fn from_bytes(bytes: Bytes) -> Self

Implementors§