#[repr(C)]pub struct Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,{
pub start: CLayoutOf<*const u8>,
pub len: CLayoutOf<usize>,
pub owner: CLayoutOf<*const ()>,
pub capacity: CLayoutOf<usize>,
pub vtable: CLayoutOf<NonNull<u8>>,
pub marker: CLayoutOf<PhantomData<&'a [u8]>>,
}
Expand description
A slice of bytes optimized for sharing ownership of it and its subslices.
Typically, Bytes
can constructed from &'static [u8]
, Arc<[u8]>
or Arc<T: AsRef<[u8]>>
.
Bytes
can also “inline” small enough slices: that is, if the slice is more than one byte smaller than
Bytes
memory layout (which is 40 bytes on 64bit architectures), it may be store directly in that memory
instead of through indirection.
Fields§
§start: CLayoutOf<*const u8>
The start of the slice.
len: CLayoutOf<usize>
The length of the slice.
owner: CLayoutOf<*const ()>
The owner of the slice, see Bytes::from_raw_parts
for details.
capacity: CLayoutOf<usize>
Named after the field often stored in it, but without actual semantics,
capacity
is essentially just addtional memory for owner
which may sometimes
require 2 words to be stored without reallocating. See Bytes::from_raw_parts
for details.
vtable: CLayoutOf<NonNull<u8>>
If properly aligned (i.e. least significant bit unset), a pointer to an instance of BytesVt
.
If not, the slice is actually inlined in Bytes
’s memory: the least significant byte of vtable
then is (length << 1) | 1
, and the data starts at the address of this instance of Bytes
.
marker: CLayoutOf<PhantomData<&'a [u8]>>
Trait Implementations§
Source§impl<'a> CType for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
impl<'a> CType for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
type OPAQUE_KIND = Concrete
fn short_name() -> String
fn define_self__impl( language: &dyn HeaderLanguage, definer: &mut dyn Definer, ) -> Result<()>
fn zeroed() -> Self
fn define_self( language: &dyn HeaderLanguage, definer: &mut dyn Definer, ) -> Result<()>
fn name(_language: &dyn HeaderLanguage) -> String
fn name_wrapping_var(language: &dyn HeaderLanguage, var_name: &str) -> String
Source§fn csharp_marshaler() -> Option<String>
fn csharp_marshaler() -> Option<String>
[MarshalAs(UnmanagedType.FunctionPtr)]
)Source§impl<'a> Clone for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
impl<'a> Clone for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
Source§impl<'a> ReprC for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
impl<'a> ReprC for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
impl<'a> Copy for Bytes_Layout<'a>where
*const u8: ConcreteReprC,
usize: ConcreteReprC,
*const (): ConcreteReprC,
NonNull<u8>: ConcreteReprC,
PhantomData<&'a [u8]>: ConcreteReprC,
Auto Trait Implementations§
impl<'a> !Freeze for Bytes_Layout<'a>
impl<'a> !RefUnwindSafe for Bytes_Layout<'a>
impl<'a> !Send for Bytes_Layout<'a>
impl<'a> !Sync for Bytes_Layout<'a>
impl<'a> !Unpin for Bytes_Layout<'a>
impl<'a> !UnwindSafe for Bytes_Layout<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FitForCBox for T
impl<T> FitForCBox for T
Source§type CBoxWrapped = Box_<T>
type CBoxWrapped = Box_<T>
alloc
only.Source§impl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>
Source§impl<T> UpcastAny for Twhere
T: 'static,
impl<T> UpcastAny for Twhere
T: 'static,
Source§fn upcast_any(&self) -> &(dyn Any + 'static)
fn upcast_any(&self) -> &(dyn Any + 'static)
headers
only.