pub trait Interface:
Send
+ Sync
+ Unpin
+ 'static {
// Required methods
fn get_info(&self) -> Cow<'_, DeviceInfo>;
fn read(
&self,
device_block_offset: u64,
block_count: u32,
vmo: &Arc<Vmo>,
vmo_offset: u64,
opts: ReadOptions,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send;
fn write(
&self,
device_block_offset: u64,
block_count: u32,
vmo: &Arc<Vmo>,
vmo_offset: u64,
opts: WriteOptions,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send;
fn flush(
&self,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send;
fn trim(
&self,
device_block_offset: u64,
block_count: u32,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send;
// Provided methods
fn open_session(
&self,
session_manager: Arc<SessionManager<Self>>,
stream: SessionRequestStream,
offset_map: OffsetMap,
block_size: u32,
) -> impl Future<Output = Result<(), Error>> + Send { ... }
fn on_attach_vmo(
&self,
_vmo: &Vmo,
) -> impl Future<Output = Result<(), Status>> + Send { ... }
fn on_detach_vmo(&self, _vmo: &Vmo) { ... }
fn get_volume_info(
&self,
) -> impl Future<Output = Result<(VolumeManagerInfo, VolumeInfo), Status>> + Send { ... }
fn query_slices(
&self,
_start_slices: &[u64],
) -> impl Future<Output = Result<Vec<VsliceRange>, Status>> + Send { ... }
fn extend(
&self,
_start_slice: u64,
_slice_count: u64,
) -> impl Future<Output = Result<(), Status>> + Send { ... }
fn shrink(
&self,
_start_slice: u64,
_slice_count: u64,
) -> impl Future<Output = Result<(), Status>> + Send { ... }
}Required Methods§
Sourcefn get_info(&self) -> Cow<'_, DeviceInfo>
fn get_info(&self) -> Cow<'_, DeviceInfo>
Called to get block/partition information.
Sourcefn read(
&self,
device_block_offset: u64,
block_count: u32,
vmo: &Arc<Vmo>,
vmo_offset: u64,
opts: ReadOptions,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send
fn read( &self, device_block_offset: u64, block_count: u32, vmo: &Arc<Vmo>, vmo_offset: u64, opts: ReadOptions, trace_flow_id: Option<NonZero<u64>>, ) -> impl Future<Output = Result<(), Status>> + Send
Called for a request to read bytes.
Implementations are responsible for checking that the request block range
([device_block_offset, device_block_offset + block_count)) falls within valid
device/partition bounds, and returning Err(zx::Status::OUT_OF_RANGE) if it is out of
bounds.
Sourcefn write(
&self,
device_block_offset: u64,
block_count: u32,
vmo: &Arc<Vmo>,
vmo_offset: u64,
opts: WriteOptions,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send
fn write( &self, device_block_offset: u64, block_count: u32, vmo: &Arc<Vmo>, vmo_offset: u64, opts: WriteOptions, trace_flow_id: Option<NonZero<u64>>, ) -> impl Future<Output = Result<(), Status>> + Send
Called for a request to write bytes.
Implementations are responsible for checking that the request block range
([device_block_offset, device_block_offset + block_count)) falls within valid
device/partition bounds, and returning Err(zx::Status::OUT_OF_RANGE) if it is out of
bounds.
Sourcefn flush(
&self,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send
fn flush( &self, trace_flow_id: Option<NonZero<u64>>, ) -> impl Future<Output = Result<(), Status>> + Send
Called to flush the device.
Sourcefn trim(
&self,
device_block_offset: u64,
block_count: u32,
trace_flow_id: Option<NonZero<u64>>,
) -> impl Future<Output = Result<(), Status>> + Send
fn trim( &self, device_block_offset: u64, block_count: u32, trace_flow_id: Option<NonZero<u64>>, ) -> impl Future<Output = Result<(), Status>> + Send
Called to trim a region.
Implementations are responsible for checking that the request block range
([device_block_offset, device_block_offset + block_count)) falls within valid
device/partition bounds, and returning Err(zx::Status::OUT_OF_RANGE) if it is out of
bounds.
Provided Methods§
Sourcefn open_session(
&self,
session_manager: Arc<SessionManager<Self>>,
stream: SessionRequestStream,
offset_map: OffsetMap,
block_size: u32,
) -> impl Future<Output = Result<(), Error>> + Send
fn open_session( &self, session_manager: Arc<SessionManager<Self>>, stream: SessionRequestStream, offset_map: OffsetMap, block_size: u32, ) -> impl Future<Output = Result<(), Error>> + Send
Runs stream to completion.
offset_map is provided by the client, and is used to remap requests. The extents in
offset_map are already validated to be within the range of the partition (as determined by
the [PartitionInfo::block_count] field). The implementation is expected to apply these
mappings to all FIFO requests, and to ensure all FIFO requests fit within the logical
extents of the offset map. Note that the default implementation does this for you, and that
is correct for most implementations.
Implementors can override this method if they want to create a passthrough session instead
(and can use PassthroughSession below to do so). Generally, a passthrough session would
open a session to its underlying device with an offset map applied
(fuchsia.storage.block.Block/OpenSessionWithOptions), which remaps and restricts
requests to the range the partition should have access to.
Nested mappings (i.e. the case when offset_map is non-empty, but the implementation
creates a passthrough session with its own mapping) would need to be composed by the
implementation. At this time, no implementations of passthrough sessions support nested
mappings, but we can add support as needed.
If the implementor uses a PassthroughSession, the following Interface methods
will not be called, and can be stubbed out:
- on_attach_vmo
- on_detach_vmo
- read
- write
- flush
- trim
Sourcefn on_attach_vmo(
&self,
_vmo: &Vmo,
) -> impl Future<Output = Result<(), Status>> + Send
fn on_attach_vmo( &self, _vmo: &Vmo, ) -> impl Future<Output = Result<(), Status>> + Send
Called whenever a VMO is attached, prior to the VMO’s usage in any other methods. Whilst
the VMO is attached, vmo will keep the same address so it is safe to use the pointer
value (as, say, a key into a HashMap).
Sourcefn on_detach_vmo(&self, _vmo: &Vmo)
fn on_detach_vmo(&self, _vmo: &Vmo)
Called whenever a VMO is detached.
Sourcefn get_volume_info(
&self,
) -> impl Future<Output = Result<(VolumeManagerInfo, VolumeInfo), Status>> + Send
fn get_volume_info( &self, ) -> impl Future<Output = Result<(VolumeManagerInfo, VolumeInfo), Status>> + Send
Called to handle the GetVolumeInfo FIDL call.
Sourcefn query_slices(
&self,
_start_slices: &[u64],
) -> impl Future<Output = Result<Vec<VsliceRange>, Status>> + Send
fn query_slices( &self, _start_slices: &[u64], ) -> impl Future<Output = Result<Vec<VsliceRange>, Status>> + Send
Called to handle the QuerySlices FIDL call.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".