Skip to main content

IoCopyable

Trait IoCopyable 

Source
pub trait IoCopyable: IoBackend {
    // Required methods
    unsafe fn copy_from_io(view: Self::View<'_, [u8]>, buffer: *mut u8);
    unsafe fn copy_to_io(view: Self::View<'_, [u8]>, buffer: *const u8);

    // Provided methods
    fn copy_read<T: FromBytes>(view: Self::View<'_, T>) -> T { ... }
    fn copy_write<T: IntoBytes>(view: Self::View<'_, T>, value: T) { ... }
}
Expand description

Trait indicating that an I/O backend supports memory copy operations.

Required Methods§

Source

unsafe fn copy_from_io(view: Self::View<'_, [u8]>, buffer: *mut u8)

Copy contents of view to buffer.

§Safety
  • buffer is valid for volatile write for view.size() bytes.
  • buffer should not overlap with view.
Source

unsafe fn copy_to_io(view: Self::View<'_, [u8]>, buffer: *const u8)

Copy contents from buffer to view.

§Safety
  • buffer is valid for volatile read for view.size() bytes.
  • buffer should not overlap with view.

Provided Methods§

Source

fn copy_read<T: FromBytes>(view: Self::View<'_, T>) -> T

Copy from view and return the value.

Source

fn copy_write<T: IntoBytes>(view: Self::View<'_, T>, value: T)

Copy value to view.

Destructor of value will not be executed, consistent with zerocopy::transmute.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§