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
use crate::enums::BitmapFormat;
use crate::utility::macros::macros::get_function_result_number;
use crate::{Framebuffer, VboxError};
impl Framebuffer {
/// Frame buffer width, in pixels.
///
/// Returns u32 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let width = framebuffer.get_width().unwrap();
pub fn get_width(&self) -> Result<u32, VboxError> {
get_function_result_number!(self.object, GetWidth, u32)
}
/// Frame buffer height, in pixels.
///
/// Returns u32 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let height = framebuffer.get_height().unwrap();
pub fn get_height(&self) -> Result<u32, VboxError> {
get_function_result_number!(self.object, GetHeight, u32)
}
/// Color depth, in bits per pixel.
///
/// Returns u32 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let bits_per_pixel = framebuffer.get_bits_per_pixel().unwrap();
pub fn get_bits_per_pixel(&self) -> Result<u32, VboxError> {
get_function_result_number!(self.object, GetBitsPerPixel, u32)
}
/// Scan line size, in bytes.
///
/// Returns u32 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let bytes_per_line = framebuffer.get_bytes_per_line().unwrap();
pub fn get_bytes_per_line(&self) -> Result<u32, VboxError> {
get_function_result_number!(self.object, GetBytesPerLine, u32)
}
/// Frame buffer pixel format.
///
/// Returns [`BitmapFormat`] 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let pixel_format = framebuffer.get_pixel_format().unwrap();
pub fn get_pixel_format(&self) -> Result<BitmapFormat, VboxError> {
let pixel_format = get_function_result_number!(self.object, GetPixelFormat, u32)?;
Ok(BitmapFormat::from(pixel_format))
}
/// Hint from the frame buffer about how much of the standard screen height it wants to use for itself.
///
/// This information is exposed to the guest through the VESA BIOS and VMMDev interface so that it can use it for determining its video mode table. It is not guaranteed that the guest respects the value.
///
/// Returns u32 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let height_reduction = framebuffer.get_height_reduction().unwrap();
pub fn get_height_reduction(&self) -> Result<u32, VboxError> {
get_function_result_number!(self.object, GetHeightReduction, u32)
}
/// Hint from the frame buffer about how much of the standard screen height it wants to use for itself.
///
/// This information is exposed to the guest through the VESA BIOS and VMMDev interface so that it can use it for determining its video mode table. It is not guaranteed that the guest respects the value.
///
/// Returns i64 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 mut session = Session::init().unwrap();
/// let machine = vbox.
/// find_machines("Freebsd_14").unwrap();
///
/// machine.lock_machine(&mut session, SessionType::Shared).unwrap();
///
/// let console = session.get_console().unwrap();
///
/// let mut display = console.get_display().unwrap();
/// let framebuffer = display.query_framebuffer(0).unwrap();
/// let win_id = framebuffer.get_win_id().unwrap();
pub fn get_win_id(&self) -> Result<i64, VboxError> {
get_function_result_number!(self.object, GetWinId, i64)
}
}