Struct CSTL_Type

Source
#[repr(C)]
pub struct CSTL_Type { pub size: usize, pub size_rcp: usize, pub size_rcp_sh: u8, pub align_lg: u8, pub use_move_from: u8, pub internal_flags: u8, pub copy_from: Option<unsafe extern "C" fn(new_instance: *mut c_void, src: *const c_void)>, pub move_from: Option<unsafe extern "C" fn(new_instance: *mut c_void, src: *mut c_void)>, pub destroy: Option<unsafe extern "C" fn(instance: *mut c_void)>, }
Expand description

Basic type info used in place of a type template parameter.

Two CSTL_Type instances are compatible iff their size and alignment are equal and the bound functions can operate interchangeably.

It is a logic error to use incompatible CSTL_Type instances one after another when manipulating an object.

Fields§

§size: usize

Size of the type in bytes, including any padding bytes.

Must be a non-zero multiple of 1 << align_lg.

§size_rcp: usize

Fixed point reciprocal of the type’s size, used for fast division and remainder operations.

Calculated automatically by CSTL_define_*_type.

§size_rcp_sh: u8

Right shift of the fixed point reciprocal of the type’s size, used for fast division and remainder operations.

Calculated automatically by CSTL_define_*_type.

§align_lg: u8

Natural alignment of the type in bytes (log2).

Calculated automatically by CSTL_define_*_type.

§use_move_from: u8

Determines whether move_from can be called on a void* pointer to an object of this type.

Set by CSTL_define_*_type or manually.

§internal_flags: u8

Opaque bitfield with unstable ABI.

§copy_from: Option<unsafe extern "C" fn(new_instance: *mut c_void, src: *const c_void)>

Bound copy constructor function.

It is NOT permitted to mutate the source.

If null a memmove(new_instance, src, size) will be used in its stead.

§move_from: Option<unsafe extern "C" fn(new_instance: *mut c_void, src: *mut c_void)>

Bound move constructor function.

It is permitted to mutate the source, therefore it is suitable for a move constructor.

Remember that the moved-from object must stay in a valid state and be able to be destroyed after this call.

If null a memmove(new_instance, src, size) will be used in its stead.

§destroy: Option<unsafe extern "C" fn(instance: *mut c_void)>

Bound destructor function.

If null a memset(instance, 0xDE, size) will be used in its stead.

Trait Implementations§

Source§

impl Clone for CSTL_Type

Source§

fn clone(&self) -> CSTL_Type

Returns a copy 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 Debug for CSTL_Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for CSTL_Type

Auto Trait Implementations§

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> 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> 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> 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.