virtualbox_rs/token/implementation.rs
1use crate::{Token, VboxError};
2use crate::utility::macros::macros::get_function_result_unit;
3
4impl Token {
5 /// Releases this token.
6 ///
7 /// 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.
8 ///
9 /// # Returns
10 ///
11 /// Returns () on success, or a [`VboxError`] on failure.
12 ///
13 /// # Example
14 ///
15 /// ```no_run
16 ///
17 /// use virtualbox_rs::VirtualBox;
18 ///
19 /// let vbox = VirtualBox::init().unwrap();
20 /// let mediums = vbox.get_hard_disks().unwrap();
21 /// let medium = mediums.get(0).unwrap();
22 /// let token = medium.lock_write().unwrap();
23 /// token.abandon().unwrap();
24 ///```
25 pub fn abandon(&self) -> Result<(), VboxError> {
26 get_function_result_unit!(self.object, Abandon)
27 }
28
29 /// Purely a NOOP.
30 ///
31 /// 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.
32 ///
33 /// # Returns
34 ///
35 /// Returns () on success, or a [`VboxError`] on failure.
36 ///
37 /// # Example
38 ///
39 /// ```no_run
40 ///
41 /// use virtualbox_rs::VirtualBox;
42 ///
43 /// let vbox = VirtualBox::init().unwrap();
44 /// let mediums = vbox.get_hard_disks().unwrap();
45 /// let medium = mediums.get(0).unwrap();
46 /// let token = medium.lock_write().unwrap();
47 /// token.dummy().unwrap();
48 ///```
49 pub fn dummy(&self) -> Result<(), VboxError> {
50 get_function_result_unit!(self.object, Dummy)
51 }
52}