#![allow(non_camel_case_types)]
#![no_std]
#[cfg(feature = "alloc")]
extern crate alloc;
use core::ptr::NonNull;
pub enum xcb_connection_t {}
pub unsafe trait AsRawXcbConnection {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t;
}
unsafe impl<T: AsRawXcbConnection + ?Sized> AsRawXcbConnection for &T {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
unsafe impl<T: AsRawXcbConnection + ?Sized> AsRawXcbConnection for &mut T {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
#[cfg(feature = "alloc")]
unsafe impl<T: AsRawXcbConnection + ?Sized> AsRawXcbConnection for alloc::boxed::Box<T> {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
#[cfg(feature = "alloc")]
unsafe impl<T: AsRawXcbConnection + ?Sized> AsRawXcbConnection for alloc::rc::Rc<T> {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
#[cfg(feature = "alloc")]
unsafe impl<T: AsRawXcbConnection + ?Sized> AsRawXcbConnection for alloc::sync::Arc<T> {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
#[cfg(feature = "alloc")]
unsafe impl<T: AsRawXcbConnection + alloc::borrow::ToOwned + ?Sized> AsRawXcbConnection
for alloc::borrow::Cow<'_, T>
{
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
(**self).as_raw_xcb_connection()
}
}
pub struct ValidConnection(NonNull<xcb_connection_t>);
impl ValidConnection {
pub unsafe fn new(ptr: *mut xcb_connection_t) -> Self {
Self(NonNull::new_unchecked(ptr))
}
}
unsafe impl AsRawXcbConnection for ValidConnection {
fn as_raw_xcb_connection(&self) -> *mut xcb_connection_t {
self.0.as_ptr()
}
}