rhwp/wmf/parser/objects/structure/rect_l.rs
1/// The RectL Object defines a rectangle.
2///
3/// A rectangle defined with a RectL Object is filled up to— but not
4/// including—the right column and bottom row of pixels.
5#[derive(Clone, Debug)]
6pub struct RectL {
7 /// Left (4 bytes): A 32-bit signed integer that defines the x coordinate,
8 /// in logical coordinates, of the upper-left corner of the rectangle.
9 pub left: i32,
10 /// Top (4 bytes): A 32-bit signed integer that defines the y coordinate,
11 /// in logical coordinates, of the upper-left corner of the rectangle.
12 pub top: i32,
13 /// Right (4 bytes): A 32-bit signed integer that defines the x coordinate,
14 /// in logical coordinates, of the lower-right corner of the rectangle.
15 pub right: i32,
16 /// Bottom (4 bytes): A 32-bit signed integer that defines y coordinate, in
17 /// logical coordinates, of the lower-right corner of the rectangle.
18 pub bottom: i32,
19}
20
21impl RectL {
22 #[cfg_attr(feature = "tracing", tracing::instrument(
23 level = tracing::Level::TRACE,
24 skip_all,
25 err(level = tracing::Level::ERROR, Display),
26 ))]
27 pub fn parse<R: crate::wmf::Read>(
28 buf: &mut R,
29 ) -> Result<(Self, usize), crate::wmf::parser::ParseError> {
30 let ((left, left_bytes), (top, top_bytes), (right, right_bytes), (bottom, bottom_bytes)) = (
31 crate::wmf::parser::read_i32_from_le_bytes(buf)?,
32 crate::wmf::parser::read_i32_from_le_bytes(buf)?,
33 crate::wmf::parser::read_i32_from_le_bytes(buf)?,
34 crate::wmf::parser::read_i32_from_le_bytes(buf)?,
35 );
36
37 Ok((
38 Self {
39 left,
40 top,
41 right,
42 bottom,
43 },
44 left_bytes + top_bytes + right_bytes + bottom_bytes,
45 ))
46 }
47}