Skip to main content

Snapshot

Struct Snapshot 

Source
pub struct Snapshot { /* private fields */ }
Expand description

The Snapshot interface represents a snapshot of the virtual machine.

Reference to the official documentation:

https://www.virtualbox.org/sdkref/interface_i_snapshot.html

Implementations§

Source§

impl Snapshot

Source

pub fn get_id(&self) -> Result<&'static str, VboxError>

UUID of the snapshot.

§Returns

Returns &str on success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let id = snapshot.get_id().unwrap();
Source

pub fn get_name(&self) -> Result<&'static str, VboxError>

Short name of the snapshot.

§Returns

Returns &str on success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let name = snapshot.get_name().unwrap();
Source

pub fn set_name(&self, name: &str) -> Result<(), VboxError>

Short name of the snapshot.

§Arguments
  • name - &str. Short name of the snapshot.
§Returns

Returns () success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

snapshot.set_name("Snapshot_1").unwrap();
Source

pub fn get_description(&self) -> Result<&'static str, VboxError>

Optional description of the snapshot.

§Returns

Returns &str on success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let description = snapshot.get_description().unwrap();
Source

pub fn set_description(&self, name: &str) -> Result<(), VboxError>

Optional description of the snapshot.

§Arguments
  • description - &str. Optional description of the snapshot.
§Returns

Returns () success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

snapshot.set_description("description").unwrap();
Source

pub fn get_time_stamp(&self) -> Result<i64, VboxError>

Timestamp of the snapshot, in milliseconds since 1970-01-01 UTC.

§Returns

Returns i64 success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let time_stamp = snapshot.get_time_stamp().unwrap();
Source

pub fn get_online(&self) -> Result<bool, VboxError>

true if this snapshot is an online snapshot and false otherwise.

When this attribute is true, the Machine::get_state_file_path attribute of the machine object associated with this snapshot will point to the saved state file. Otherwise, it will be an empty string.

§Returns

Returns bool success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let time_stamp = snapshot.get_time_stamp().unwrap();
Source

pub fn get_machine(&self) -> Result<Machine, VboxError>

Virtual machine this snapshot is taken on.

This object stores all settings the machine had when taking this snapshot.

The returned machine object is immutable, i.e. no any settings can be changed.
§Returns

Returns Machine success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.get_current_snapshot().unwrap().unwrap();

let machine = snapshot.get_machine().unwrap();
Source

pub fn get_parent(&self) -> Result<Option<Snapshot>, VboxError>

Parent snapshot (a snapshot this one is based on), or None if the snapshot has no parent (i.e. is the first snapshot).

§Returns

Returns Option<Snapshot> success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.find_snapshot("Snapshot_2").unwrap();

let machine = snapshot.get_machine().unwrap();
Source

pub fn get_children(&self) -> Result<Vec<Snapshot>, VboxError>

Child snapshots (all snapshots having this one as a parent).

By inspecting this attribute starting with a machine’s root snapshot (which can be obtained by calling Machine::find_snapshot with empty UUID), a machine’s snapshots tree can be iterated over.

§Returns

Returns Vec<Snapshot> success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.find_snapshot("Snapshot_2").unwrap();

let children = snapshot.get_children().unwrap();
Source

pub fn get_children_count(&self) -> Result<u32, VboxError>

Returns the number of direct children of this snapshot.

§Returns

Returns Vec<Snapshot> success, or a VboxError on failure.

§Example

use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let machine = vbox.
        find_machines("Freebsd_14").unwrap();
let snapshot = machine.find_snapshot("Snapshot_2").unwrap();

let count = snapshot.get_children_count().unwrap();

Trait Implementations§

Source§

impl Debug for Snapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Snapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Snapshot

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.