|
| 1 | +//! Local versions of types that bindgen would use. |
| 2 | +
|
| 3 | +/// This represents an incomplete array field at the end of a struct. |
| 4 | +/// |
| 5 | +/// This is called `__IncompleteArrayField` in bindgen bindings. |
| 6 | +#[repr(C)] |
| 7 | +#[derive(Default)] |
| 8 | +pub struct IncompleteArrayField<T>(::core::marker::PhantomData<T>, [T; 0]); |
| 9 | + |
| 10 | +#[allow(missing_docs)] |
| 11 | +impl<T> IncompleteArrayField<T> { |
| 12 | + #[inline] |
| 13 | + pub const fn new() -> Self { |
| 14 | + IncompleteArrayField(::core::marker::PhantomData, []) |
| 15 | + } |
| 16 | + |
| 17 | + #[inline] |
| 18 | + pub fn as_ptr(&self) -> *const T { |
| 19 | + self as *const _ as *const T |
| 20 | + } |
| 21 | + |
| 22 | + #[inline] |
| 23 | + pub fn as_mut_ptr(&mut self) -> *mut T { |
| 24 | + self as *mut _ as *mut T |
| 25 | + } |
| 26 | + |
| 27 | + #[inline] |
| 28 | + pub unsafe fn as_slice(&self, len: usize) -> &[T] { |
| 29 | + ::core::slice::from_raw_parts(self.as_ptr(), len) |
| 30 | + } |
| 31 | + |
| 32 | + #[inline] |
| 33 | + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { |
| 34 | + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +impl<T> ::core::fmt::Debug for IncompleteArrayField<T> { |
| 39 | + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { |
| 40 | + fmt.write_str("IncompleteArrayField") |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +/// This represents a toplevel union field. |
| 45 | +/// |
| 46 | +/// This is called `__BindgenUnionField` in bindgen bindings. |
| 47 | +pub struct UnionField<T>(::core::marker::PhantomData<T>); |
| 48 | + |
| 49 | +#[allow(missing_docs)] |
| 50 | +impl<T> UnionField<T> { |
| 51 | + #[inline] |
| 52 | + pub const fn new() -> Self { |
| 53 | + UnionField(::core::marker::PhantomData) |
| 54 | + } |
| 55 | + |
| 56 | + #[inline] |
| 57 | + pub unsafe fn as_ref(&self) -> &T { |
| 58 | + ::core::mem::transmute(self) |
| 59 | + } |
| 60 | + |
| 61 | + #[inline] |
| 62 | + pub unsafe fn as_mut(&mut self) -> &mut T { |
| 63 | + ::core::mem::transmute(self) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +impl<T> ::core::default::Default for UnionField<T> { |
| 68 | + #[inline] |
| 69 | + fn default() -> Self { |
| 70 | + Self::new() |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +impl<T> ::core::clone::Clone for UnionField<T> { |
| 75 | + #[inline] |
| 76 | + fn clone(&self) -> Self { |
| 77 | + *self |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +impl<T> ::core::marker::Copy for UnionField<T> {} |
| 82 | + |
| 83 | +impl<T> ::core::fmt::Debug for UnionField<T> { |
| 84 | + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { |
| 85 | + fmt.write_str("UnionField") |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +impl<T> ::core::hash::Hash for UnionField<T> { |
| 90 | + fn hash<H: ::core::hash::Hasher>(&self, _state: &mut H) {} |
| 91 | +} |
| 92 | + |
| 93 | +impl<T> ::core::cmp::PartialEq for UnionField<T> { |
| 94 | + fn eq(&self, _other: &UnionField<T>) -> bool { |
| 95 | + true |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +impl<T> ::core::cmp::Eq for UnionField<T> {} |
0 commit comments