Struct Bytes_Layout

Source
#[repr(C)]
pub struct Bytes_Layout<'a>{ 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>

Source§

type OPAQUE_KIND = Concrete

Source§

fn short_name() -> String

Source§

fn define_self__impl( language: &dyn HeaderLanguage, definer: &mut dyn Definer, ) -> Result<()>

Source§

fn zeroed() -> Self

Source§

fn define_self( language: &dyn HeaderLanguage, definer: &mut dyn Definer, ) -> Result<()>

Source§

fn name(_language: &dyn HeaderLanguage) -> String

Source§

fn name_wrapping_var(language: &dyn HeaderLanguage, var_name: &str) -> String

Source§

fn csharp_marshaler() -> Option<String>

Optional marshaler attached to the type (e.g., [MarshalAs(UnmanagedType.FunctionPtr)])
Source§

impl<'a> Clone for Bytes_Layout<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> ReprC for Bytes_Layout<'a>

Source§

type CLayout = Bytes_Layout<'a>

The CType having the same layout as Self.
Source§

fn is_valid(_: &Self::CLayout) -> bool

Sanity checks that can be performed on an instance of the CType layout. Read more
Source§

impl<'a> Copy for Bytes_Layout<'a>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out<'out>(&'out mut self) -> Out<'out, T>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> FitForCBox for T

Source§

type CBoxWrapped = Box_<T>

Available on crate feature alloc only.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ManuallyDropMut for T

Source§

type Ret = ManuallyDrop<T>

Source§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UpcastAny for T
where T: 'static,

Source§

fn upcast_any(&self) -> &(dyn Any + 'static)

Available on crate feature headers only.
Source§

impl<F> ZeroSizedElseWrathOfTheGඞds for F