pub struct PreparedDataMapping<'a, S: Storage + 'static> {
storage: &'a S,
offset: u64,
length: u64,
state: Option<Box<dyn Any>>,
}Expand description
Data mapping that has been prepared, but not committed yet.
Returned by FormatAccess::prepare_data_mapping(): Says where to write the data for the
range that is to be mapped. Once that data has been written, pass this object to
FormatAccess::commit_data_mapping() to make the mapping visible.
Dropping this object without committing it discards any prepared mapping change.
Until this object is committed or dropped, any other I/O on the image may wait for it.
Fields§
§storage: &'a SStorage object to write the data to.
offset: u64Offset in storage to write the data to.
length: u64Length of the mapping.
state: Option<Box<dyn Any>>Driver-specific state required to commit this mapping; None if nothing needs to be
committed.
Implementations§
Source§impl<'a, S: Storage + 'static> PreparedDataMapping<'a, S>
impl<'a, S: Storage + 'static> PreparedDataMapping<'a, S>
Sourcepub fn existing(storage: &'a S, offset: u64, length: u64) -> Self
pub fn existing(storage: &'a S, offset: u64, length: u64) -> Self
Create a prepared mapping that does not require anything to be committed.
For use by format drivers, e.g. when the mapping exists already.
Sourcepub fn to_commit(
storage: &'a S,
offset: u64,
length: u64,
state: Box<dyn Any>,
) -> Self
pub fn to_commit( storage: &'a S, offset: u64, length: u64, state: Box<dyn Any>, ) -> Self
Create a prepared mapping that must be committed, using the driver-specific state.
For use by format drivers. Dropping state must discard the prepared mapping.
Sourcepub fn offset(&self) -> u64
pub fn offset(&self) -> u64
Offset in Self::storage() to write the data to.
Sourcepub fn is_nonblocking(&self) -> bool
pub fn is_nonblocking(&self) -> bool
Whether holding this object can delay other I/O on the image.
true means the range only becomes visible once it is committed, and other I/O on the
image may be blocked in order not to interfere with that.
false means holding it will never delay other I/O. In this case, the mapping is visible
already: the range keeps reading as it does now, and committing it will most likely do
nothing (FormatAccess::commit_data_mapping() must still be called by users, though).
Sourcepub fn into_state(self) -> Option<Box<dyn Any>>
pub fn into_state(self) -> Option<Box<dyn Any>>
Take the driver-specific state, if any.
For use by format drivers.
Sourcepub(crate) fn limit_length(&mut self, max_length: u64)
pub(crate) fn limit_length(&mut self, max_length: u64)
Limit the length of the mapping to max_length.