spice-client-glib 0.8.0

Rust bindings for the Spice client library
Documentation
use glib::translate::*;

use crate::DisplayChannel;

#[derive(Debug, Clone)]
pub struct GlScanout2(ffi::SpiceGlScanout2);

impl GlScanout2 {
    #[cfg(unix)]
    pub fn fd(&self) -> &[std::os::unix::io::RawFd; 4] {
        &self.0.fd
    }

    pub fn width(&self) -> u32 {
        self.0.width
    }

    pub fn height(&self) -> u32 {
        self.0.height
    }

    pub fn offset(&self) -> &[u32; 4] {
        &self.0.offset
    }

    pub fn stride(&self) -> &[u32; 4] {
        &self.0.stride
    }

    pub fn num_planes(&self) -> u32 {
        self.0.num_planes
    }

    pub fn format(&self) -> u32 {
        self.0.format
    }

    pub fn y0_top(&self) -> bool {
        unsafe { from_glib(self.0.y0top) }
    }

    pub fn modifier(&self) -> u64 {
        self.0.modifier
    }
}

impl DisplayChannel {
    #[cfg(feature = "v0_43")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v0_43")))]
    #[doc(alias = "spice_display_channel_get_gl_scanout2")]
    pub fn gl_scanout2(&self) -> Option<GlScanout2> {
        unsafe {
            let ptr = ffi::spice_display_channel_get_gl_scanout2(self.to_glib_none().0);
            if ptr.is_null() {
                None
            } else {
                Some(GlScanout2(*ptr))
            }
        }
    }
}