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 more