Struct vm_control::snapshot_format::SnapshotWriter
source · pub struct SnapshotWriter {
dir: PathBuf,
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 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.