Struct chronicle::ScopedMut

pub struct ScopedMut<'a, T: Closeable> { /* private fields */ }
Expand description

A wrapper for a non-shared (mutable) reference to a Closeable type.

The wrapped item is reached by de-referencing the Scoped handle, and is automatically close()d when the Scoped handle is dropped.

Note that de-referencing returns a shared reference to the wrapped item. A mutable reference is obtained by calling as_mut(), which returns a Pin<&mut T>

Implementations§

Get a non-shared (mutable) reference to the contained item

Note that the returned type is Pin<&mut T> rather than &mut T (owing to constraints imposed by cxx)

Example

The scoped bytes writer returned by ExcerptAppender::scoped_bytes_writer() is a ScopedMut wrapping a BytesWriter.

let mut appender = queue.acquire_appender().unwrap();
let mut bytes = appender.scoped_bytes_writer(MSGSIZE);
let slice = bytes.as_mut().as_slice();

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.