1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
use vbox_raw::sys_lib::{IPlatformARM, IPlatformProperties, IPlatformX86};
use crate::{Platform, PlatformARM, PlatformProperties, PlatformX86, VboxError};
use crate::enums::{ChipsetType, IommuType, PlatformArchitecture};
use crate::utility::macros::macros::{get_function_result_bool, get_function_result_number, get_function_result_pointer, get_function_result_unit};
impl Platform {
/// Returns the platform architecture.
///
/// # Returns
///
/// Returns [`PlatformArchitecture`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let architecture = platform.get_architecture().unwrap();
pub fn get_architecture(&self) -> Result<PlatformArchitecture, VboxError> {
let architecture = get_function_result_number!(self.object, GetArchitecture, u32)?;
Ok(PlatformArchitecture::from(architecture))
}
/// The platform architecture.
///
/// # Arguments
///
/// * `architecture` - [`PlatformArchitecture`] The new platform architecture.
///
/// # Returns
///
/// Returns () on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::{PlatformArchitecture, SessionType};
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// platform.set_architecture(PlatformArchitecture::X86).unwrap();
pub fn set_architecture(&self, architecture: PlatformArchitecture) -> Result<(), VboxError> {
let architecture = architecture.into();
get_function_result_unit!(self.object, SetArchitecture, architecture)
}
/// Returns the platform architecture.
///
/// # Returns
///
/// Returns [`PlatformProperties`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let properties = platform.get_properties().unwrap();
pub fn get_properties(&self) -> Result<PlatformProperties, VboxError> {
let properties = get_function_result_pointer!(self.object, GetProperties, *mut IPlatformProperties)?;
Ok(PlatformProperties::new(properties))
}
/// Platform object for x86-specific platform properties.
///
/// # Returns
///
/// Returns [`PlatformX86`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let platform_x86 = platform.get_x86().unwrap();
pub fn get_x86(&self) -> Result<PlatformX86, VboxError> {
let platform_x86 = get_function_result_pointer!(self.object, GetX86, *mut IPlatformX86)?;
Ok(PlatformX86::new(platform_x86))
}
/// Platform object for ARM-specific platform properties.
///
/// # Returns
///
/// Returns [`PlatformARM`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let platform_arm = platform.get_arm().unwrap();
pub fn get_arm(&self) -> Result<PlatformARM, VboxError> {
let platform_arm = get_function_result_pointer!(self.object, GetARM, *mut IPlatformARM)?;
Ok(PlatformARM::new(platform_arm))
}
/// Chipset type used in this VM.
///
/// # Returns
///
/// Returns [`ChipsetType`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let chipset_type = platform.get_chipset_type().unwrap();
pub fn get_chipset_type(&self) -> Result<ChipsetType, VboxError> {
let chipset_type = get_function_result_number!(self.object, GetChipsetType, u32)?;
Ok(ChipsetType::from(chipset_type))
}
/// Chipset type used in this VM.
///
/// # Arguments
///
/// * `architecture` - [`ChipsetType`] Chipset type used in this VM.
///
/// # Returns
///
/// Returns () on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::{ChipsetType, SessionType};
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// platform.set_chipset_type(ChipsetType::ICH9).unwrap();
pub fn set_chipset_type(&self, chipset_type: ChipsetType) -> Result<(), VboxError> {
let chipset_type = chipset_type.into();
get_function_result_unit!(self.object, SetChipsetType, chipset_type)
}
/// IOMMU type used in this VM.
///
/// # Returns
///
/// Returns [`IommuType`] on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let iommu_type = platform.get_iommu_type().unwrap();
pub fn get_iommu_type(&self) -> Result<IommuType, VboxError> {
let iommu_type = get_function_result_number!(self.object, GetIommuType, u32)?;
Ok(IommuType::from(iommu_type))
}
/// IOMMU type used in this VM.
///
/// # Arguments
///
/// * `architecture` - [`IommuType`] IOMMU type used in this VM.
///
/// # Returns
///
/// Returns () on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::{IommuType, SessionType};
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// platform.set_iommu_type(IommuType::Intel).unwrap();
pub fn set_iommu_type(&self, iommu_type: IommuType) -> Result<(), VboxError> {
let iommu_type = iommu_type.into();
get_function_result_unit!(self.object, SetIommuType, iommu_type)
}
/// When set to true, the RTC device of the virtual machine will run in UTC time, otherwise in local time.
///
/// # Returns
///
/// Returns bool on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::VirtualBox;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let platform = machine.get_platform().unwrap();
/// let rtc_use_utc = platform.get_rtc_use_utc().unwrap();
pub fn get_rtc_use_utc(&self) -> Result<bool, VboxError> {
get_function_result_bool!(self.object, GetRTCUseUTC)
}
/// When set to true, the RTC device of the virtual machine will run in UTC time, otherwise in local time.
///
/// # Arguments
///
/// * `architecture` - When set to true, the RTC device of the virtual machine will run in UTC time, otherwise in local time.
///
/// # Returns
///
/// Returns () on success, or a [`VboxError`] on failure.
///
/// # Example
///
/// ```no_run
///
/// use virtualbox_rs::{Session, VirtualBox};
/// use virtualbox_rs::enums::SessionType;
///
/// let vbox = VirtualBox::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
/// let mut session = Session::init().unwrap();
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
/// let machine_mut = session.get_machine().unwrap();
/// let platform = machine_mut.get_platform().unwrap();
/// platform.set_rtc_use_utc(true).unwrap();
pub fn set_rtc_use_utc(&self, rtc_use_utc: bool) -> Result<(), VboxError> {
let rtc_use_utc = if rtc_use_utc { 1 } else { 0 };
get_function_result_unit!(self.object, SetRTCUseUTC, rtc_use_utc)
}
}