RawBuffer

Trait RawBuffer 

Source
pub unsafe trait RawBuffer<S: ?Sized>: Buffer<S> + Clone {
    // Required methods
    fn into_raw(self) -> *const ();
    unsafe fn from_raw(ptr: *const ()) -> Self;
}
Available on crate feature raw-buffer only.
Expand description

A buffer that can be stored into a raw pointer.

The trait can be used when the actual buffer is already stored in an Arc.

§Safety

  • The slice returned by Buffer::as_slice must not be invalidated by into_raw.
  • from_raw must be pure, i.e. mem::forget(S::from_raw(ptr)) should not invalidate memory behind ptr.

Required Methods§

Source

fn into_raw(self) -> *const ()

Converts the buffer into a raw pointer.

Source

unsafe fn from_raw(ptr: *const ()) -> Self

Converts back the buffer from a raw pointer.

§Safety

The pointer must be obtained by a call to RawBuffer::into_raw.

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<S: ?Sized, B: Buffer<S> + Sync> RawBuffer<S> for Arc<B>

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

fn into_raw(self) -> *const ()

Source§

unsafe fn from_raw(ptr: *const ()) -> Self

Implementors§