Skip to main content

Driver

Trait Driver 

Source
pub trait Driver: DriverIo {
    type Options: Send;

    // Required method
    fn open(opts: Self::Options) -> StorageResult<(Self, DriverState)>
       where Self: Sized;
}
Expand description

Driver factory + I/O contract.

Driver adds backend creation on top of the runtime DriverIo operations. Public on purpose: the generic Resource::<D>::open(cancel, opts: D::Options) constructor uses D::Options as the call-site type-driver disambiguation knob — every Resource::open(token, MmapOptions { .. }) callsite resolves to Resource<MmapDriver>::open because MmapOptions = <MmapDriver as Driver>::Options.

The redundant_reexport audit lint flags the dual surface (pub use mmap::MmapOptions AND <MmapDriver as Driver>::Options = MmapOptions) — the duplication is intentional: MmapOptions is the canonical constructor type users reach via kithara_storage::MmapOptions, while the trait associated type is the bound that lets Resource::open stay generic. See crates/kithara-storage/README.md for the rationale.

Required Associated Types§

Source

type Options: Send

Configuration needed to open/create a driver instance.

Required Methods§

Source

fn open(opts: Self::Options) -> StorageResult<(Self, DriverState)>
where Self: Sized,

Open or create a new driver from options.

Returns the driver and initial state to populate Resource<D>.

§Errors

Returns error if the backing storage cannot be opened or created.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§