pub struct Token { /* private fields */ }
Expand description
The Token interface represents a token passed to an API client, which triggers cleanup actions when it is explicitly released by calling the abandon method (preferred, as it is accurately defined when the release happens), or when the object reference count drops to 0.
Reference to the official documentation:
Implementations§
Source§impl Token
impl Token
Sourcepub fn abandon(&self) -> Result<(), VboxError>
pub fn abandon(&self) -> Result<(), VboxError>
Releases this token.
Cannot be undone in any way, and makes the token object unusable (even the dummy method will return an error), ready for releasing. It is a more defined way than just letting the reference count drop to 0, because the latter (depending on the platform) can trigger asynchronous cleanup activity.
§Returns
Returns () on success, or a VboxError
on failure.
§Example
use virtualbox_rs::VirtualBox;
let vbox = VirtualBox::init().unwrap();
let mediums = vbox.get_hard_disks().unwrap();
let medium = mediums.get(0).unwrap();
let token = medium.lock_write().unwrap();
token.abandon().unwrap();
Sourcepub fn dummy(&self) -> Result<(), VboxError>
pub fn dummy(&self) -> Result<(), VboxError>
Purely a NOOP.
Useful when using proxy type API bindings (e.g. the webservice) which manage objects on behalf of the actual client, using an object reference expiration time based garbage collector.
§Returns
Returns () on success, or a VboxError
on failure.
§Example
use virtualbox_rs::VirtualBox;
let vbox = VirtualBox::init().unwrap();
let mediums = vbox.get_hard_disks().unwrap();
let medium = mediums.get(0).unwrap();
let token = medium.lock_write().unwrap();
token.dummy().unwrap();