Buffer

Trait Buffer 

Source
pub trait Buffer<S: ?Sized>:
    Sized
    + Send
    + 'static {
    // Required method
    fn as_slice(&self) -> &S;

    // Provided method
    fn is_unique(&self) -> bool { ... }
}
Expand description

A buffer that contains a slice.

Buffer needs to implement Send, as it may be dropped in another thread.

Required Methods§

Source

fn as_slice(&self) -> &S

Returns the buffer slice.

Provided Methods§

Source

fn is_unique(&self) -> bool

Returns if the buffer is unique, i.e. if this buffer is the only reference to its slice.

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 Buffer<str> for String

Source§

fn as_slice(&self) -> &str

Source§

impl Buffer<BStr> for BString

Available on crate feature bstr only.
Source§

fn as_slice(&self) -> &BStr

Source§

impl<S: Slice + ?Sized> Buffer<S> for &'static S

Source§

fn as_slice(&self) -> &S

Source§

fn is_unique(&self) -> bool

Source§

impl<S: Slice + ?Sized> Buffer<S> for Box<S>

Source§

fn as_slice(&self) -> &S

Source§

impl<S: ?Sized, B: Buffer<S> + Sync> Buffer<S> for Arc<B>

Available on non-crate feature portable-atomic or crate feature portable-atomic-util only.
Source§

fn as_slice(&self) -> &S

Source§

fn is_unique(&self) -> bool

Source§

impl<T: Send + 'static> Buffer<[T]> for Vec<T>

Source§

fn as_slice(&self) -> &[T]

Implementors§

Source§

impl<S: ?Sized, B: AsRef<S> + Send + 'static> Buffer<S> for AsMutBuffer<B>

Source§

impl<S: ?Sized, B: AsRef<S> + Send + 'static> Buffer<S> for AsRefBuffer<B>