//! Local versions of types that bindgen would use. use crate::utils::{as_mut_ptr, as_ptr}; /// This represents an incomplete array field at the end of a struct. /// /// This is called `__IncompleteArrayField` in bindgen bindings. #[repr(C)] #[derive(Default)] pub struct IncompleteArrayField(::core::marker::PhantomData, [T; 0]); #[allow(missing_docs)] impl IncompleteArrayField { #[inline] pub const fn new() -> Self { Self(::core::marker::PhantomData, []) } #[inline] pub fn as_ptr(&self) -> *const T { as_ptr(self).cast::() } #[inline] pub fn as_mut_ptr(&mut self) -> *mut T { as_mut_ptr(self).cast::() } #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { ::core::slice::from_raw_parts(self.as_ptr(), len) } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } } impl ::core::fmt::Debug for IncompleteArrayField { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("IncompleteArrayField") } } /// This represents a toplevel union field. /// /// This is called `__BindgenUnionField` in bindgen bindings. pub struct UnionField(::core::marker::PhantomData); #[allow(missing_docs)] impl UnionField { #[inline] pub const fn new() -> Self { Self(::core::marker::PhantomData) } #[inline] pub unsafe fn as_ref(&self) -> &T { ::core::mem::transmute(self) } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { ::core::mem::transmute(self) } } impl ::core::default::Default for UnionField { #[inline] fn default() -> Self { Self::new() } } impl ::core::clone::Clone for UnionField { #[inline] fn clone(&self) -> Self { *self } } impl ::core::marker::Copy for UnionField {} impl ::core::fmt::Debug for UnionField { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.write_str("UnionField") } } impl ::core::hash::Hash for UnionField { fn hash(&self, _state: &mut H) {} } impl ::core::cmp::PartialEq for UnionField { fn eq(&self, _other: &Self) -> bool { true } } impl ::core::cmp::Eq for UnionField {}