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