Skip to main content

PreparedDataMapping

Struct PreparedDataMapping 

Source
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 S

Storage object to write the data to.

§offset: u64

Offset in storage to write the data to.

§length: u64

Length 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>

Source

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.

Source

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.

Source

pub fn storage(&self) -> &'a S

Storage object to write the data to.

Source

pub fn offset(&self) -> u64

Offset in Self::storage() to write the data to.

Source

pub fn length(&self) -> u64

Length of the mapping.

Source

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).

Source

pub fn into_state(self) -> Option<Box<dyn Any>>

Take the driver-specific state, if any.

For use by format drivers.

Source

pub(crate) fn limit_length(&mut self, max_length: u64)

Limit the length of the mapping to max_length.

Trait Implementations§

Source§

impl<S: Storage + 'static> Debug for PreparedDataMapping<'_, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for PreparedDataMapping<'a, S>

§

impl<'a, S> !RefUnwindSafe for PreparedDataMapping<'a, S>

§

impl<'a, S> !Send for PreparedDataMapping<'a, S>

§

impl<'a, S> !Sync for PreparedDataMapping<'a, S>

§

impl<'a, S> Unpin for PreparedDataMapping<'a, S>

§

impl<'a, S> UnsafeUnpin for PreparedDataMapping<'a, S>

§

impl<'a, S> !UnwindSafe for PreparedDataMapping<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more