rust_spec/core_impls/
ffi.rs1#[cfg(feature = "alloc")]
2use alloc::ffi::CString;
3use core::ffi::{CStr, c_void};
4
5#[cfg(feature = "alloc")]
6use crate::drop::{AutoDrop, CustomDrop};
7use crate::{
8 NonOpaque, RustSpec, Stable, Unstable,
9 drop::NoDrop,
10 layout::{NonRobust, Robust},
11 mutability::{Exclusive, WithoutInterior},
12 niche::{WithNiche, WithoutNiche},
13 size::{self, NulTerminated},
14};
15
16unsafe impl RustSpec for c_void {
17 type Layout = Stable;
18 type Size = size::Sized<crate::Gt<crate::Zero>>;
19 type __Alignment = crate::One;
20 type Trap = NonRobust;
21 type Niche = WithNiche<Unstable>;
22 type Drop = NoDrop;
23 type Mutability = Exclusive<WithoutInterior>;
24 type Opacity = NonOpaque;
25 type __IndirectTrap = Robust;
26}
27
28unsafe impl RustSpec for CStr {
29 type Layout = Unstable;
30 type Size = NulTerminated;
31 type __Alignment = crate::One;
32 type Trap = NonRobust;
33 type Niche = WithoutNiche;
34 type Drop = NoDrop;
35 type Mutability = Exclusive<WithoutInterior>;
36 type Opacity = NonOpaque;
37 type __IndirectTrap = Robust;
38}
39
40#[cfg(feature = "alloc")]
41unsafe impl RustSpec for CString {
42 type Layout = Unstable;
43 type Size = size::Sized<crate::Gt<crate::Zero>>;
44 type __Alignment = <usize as RustSpec>::__Alignment;
45 type Trap = NonRobust;
46 type Niche = WithNiche<Unstable>;
47 type Drop = CustomDrop<AutoDrop>;
48 type Mutability = Exclusive<WithoutInterior>;
49 type Opacity = NonOpaque;
50 type __IndirectTrap = Robust;
51}