pub struct View<S> { /* private fields */ }Expand description
A view into the content of a Snapshot that can be used to
read or write into it.
There are two types of views:
CowView: A copy-on-write view where changes to the view do not affect the root snapshot.MutView: A mutable view where changes to the view modify the root snapshot.
Normal rust borrowing semantics apply, where only one mutable view can exist at a time, and multiple immutable views can exist simultaneously. Both views are tied to the lifetime with which they borrow the snapshot, so they cannot outlive the snapshot they reference.
A third type of view ArcView is similar to CowView
but must be created from a reference-counted Arc<Snapshot>.
Unlike CowView, it has no lifetime requirements.
Implementations§
Source§impl<S> View<S>
impl<S> View<S>
Sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Returns a slice containing the entire view.
This is equicalent to &view[..],
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Returns a mutable slice containing the entire view.
This is equicalent to &mut view[..],
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Returns the base mutable pointer of the view.
Sourcepub fn take_snapshot(&self) -> Result<Snapshot>
pub fn take_snapshot(&self) -> Result<Snapshot>
Creates a new snapshot from the current content of this view, including any changes made to it.
Note: This method copies the entire content of the view and depending on the size of the snapshot, it can be slow.