Skip to main content

IoBackend

Trait IoBackend 

Source
pub trait IoBackend {
    type View<'a, T: ?Sized + KnownSize>: IoBase<'a, Backend = Self, Target = T>;

    // Required methods
    fn as_ptr<'a, T: ?Sized + KnownSize>(view: Self::View<'a, T>) -> *mut T;
    unsafe fn project_view<'a, T: ?Sized + KnownSize, U: ?Sized + KnownSize>(
        view: Self::View<'a, T>,
        ptr: *mut U,
    ) -> Self::View<'a, U>;
}
Expand description

I/O backends.

This is an abstract representation to be implemented by arbitrary I/O backends (e.g. MMIO, PCI config space, etc.).

The base trait only defines the projection operations; which I/O methods are available depends on which IoCapable<T> traits are implemented for the type. For example, for MMIO regions, all widths (u8, u16, u32, and u64 on 64-bit systems) are typically supported. For PCI configuration space, u8, u16, and u32 are supported but u64 is not.

This trait is separate from the Io trait as multiple different I/O types may share the same operation.

Required Associated Types§

Source

type View<'a, T: ?Sized + KnownSize>: IoBase<'a, Backend = Self, Target = T>

View type for this I/O backend.

Required Methods§

Source

fn as_ptr<'a, T: ?Sized + KnownSize>(view: Self::View<'a, T>) -> *mut T

Convert a view to a raw pointer for projection.

The returned pointer is private implementation detail of the backend; it is likely not valid. It should not be dereferenced.

Source

unsafe fn project_view<'a, T: ?Sized + KnownSize, U: ?Sized + KnownSize>( view: Self::View<'a, T>, ptr: *mut U, ) -> Self::View<'a, U>

Project view to its subregion indicated by ptr.

If input view is valid, returned view must also be valid.

§Safety

ptr must be a projection of Self::as_ptr(view).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§