HasMemory

Trait HasMemory 

Source
pub trait HasMemory: Debug {
    // Required method
    fn memory(&self) -> impl MemoryShared;
}
Expand description

Ability to provide memory capacity in a way suitable for shared access.

This trait is typically implemented by types that accept byte sequences or sequence builders from callers. The implication is that using memory capacity obtained via this trait (or Memory, if implemented) will allow the implementing type to perform its work in the most efficient manner because the memory capacity will be pre-configured to suit the specific needs of the implementing type.

§Implementation patterns

A type implementing this trait should also implement Memory, enabling users to reserve memory capacity without needing to own an instance of the sharing-compatible form of the memory provider, which may impose extra overhead.

Required Methods§

Source

fn memory(&self) -> impl MemoryShared

Returns a sharing-compatible memory provider.

The memory capacity returned by this provider will be configured to allow the implementing type to consume/produce data with optimal efficiency.

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.

Implementors§