pixman/
trap.rs

1use crate::{ffi, Span};
2
3/// A single trap
4#[derive(Debug, Clone, Copy)]
5#[repr(transparent)]
6pub struct Trap(ffi::pixman_trap_t);
7
8impl Trap {
9    /// Initialize the trap from the provided values
10    #[inline]
11    pub fn new(top: impl Into<Span>, bot: impl Into<Span>) -> Self {
12        Self(ffi::pixman_trap_t {
13            top: top.into().into(),
14            bot: bot.into().into(),
15        })
16    }
17
18    /// Access the top value of this trap
19    #[inline]
20    pub fn top(&self) -> Span {
21        Span::from(self.0.top)
22    }
23
24    /// Access the bot value of this trap
25    #[inline]
26    pub fn bot(&self) -> Span {
27        Span::from(self.0.bot)
28    }
29}
30
31impl From<ffi::pixman_trap_t> for Trap {
32    #[inline]
33    fn from(value: ffi::pixman_trap_t) -> Self {
34        Self(value)
35    }
36}
37
38impl From<Trap> for ffi::pixman_trap_t {
39    #[inline]
40    fn from(value: Trap) -> Self {
41        value.0
42    }
43}