Struct snapshot::SnapshotWriter
source · pub struct SnapshotWriter {
pub(crate) dir: PathBuf,
pub(crate) key: Option<CryptKey>,
}
Expand description
Writer of serialized VM snapshots.
Each fragment is an opaque byte blob. Namespaces can be used to avoid fragment naming collisions between devices.
In the current implementation, fragments are files and namespaces are directories, but the API is kept abstract so that we can potentially support something like a single file archive output.
Fields§
§dir: PathBuf
§key: Option<CryptKey>
If encryption is used, the plaintext key will be stored here.
Implementations§
source§impl SnapshotWriter
impl SnapshotWriter
sourcepub fn new(root: PathBuf, encrypt: bool) -> Result<Self>
pub fn new(root: PathBuf, encrypt: bool) -> Result<Self>
Creates a new SnapshotWriter
that will writes its data to a dir at root
. The path must
not exist yet. If encryption is desired, set encrypt (Note: only supported downstream on
Windows).
sourcepub fn raw_fragment(&self, name: &str) -> Result<Box<dyn Write>>
pub fn raw_fragment(&self, name: &str) -> Result<Box<dyn Write>>
Creates a snapshot fragment and get access to the Write
impl representing it.
sourcepub fn raw_fragment_with_chunk_size(
&self,
name: &str,
chunk_size_bytes: usize,
) -> Result<Box<dyn Write>>
pub fn raw_fragment_with_chunk_size( &self, name: &str, chunk_size_bytes: usize, ) -> Result<Box<dyn Write>>
When encryption is used, allows direct control of the encrypted chunk size.
sourcepub fn write_fragment<T: Serialize>(&self, name: &str, v: &T) -> Result<()>
pub fn write_fragment<T: Serialize>(&self, name: &str, v: &T) -> Result<()>
Creates a snapshot fragment from a serialized representation of v
.
sourcepub fn add_namespace(&self, name: &str) -> Result<Self>
pub fn add_namespace(&self, name: &str) -> Result<Self>
Creates new namespace and returns a SnapshotWriter
that writes to it. Namespaces can be
nested.
Trait Implementations§
source§impl Clone for SnapshotWriter
impl Clone for SnapshotWriter
source§fn clone(&self) -> SnapshotWriter
fn clone(&self) -> SnapshotWriter
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SnapshotWriter
impl Debug for SnapshotWriter
source§impl<'de> Deserialize<'de> for SnapshotWriter
impl<'de> Deserialize<'de> for SnapshotWriter
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SnapshotWriter
impl RefUnwindSafe for SnapshotWriter
impl Send for SnapshotWriter
impl Sync for SnapshotWriter
impl Unpin for SnapshotWriter
impl UnwindSafe for SnapshotWriter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)