pub struct AllocAlignment { /* private fields */ }
Available on crate feature
unstable
only.Expand description
alignment in powers of 2: 0 == 1-byte alignment, 1 == 2byte, 2 == 4byte, 3 == 8byte etc
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Implementations§
Source§impl AllocAlignment
impl AllocAlignment
pub const ALIGN_1_BYTE: AllocAlignment
pub const ALIGN_2_BYTES: AllocAlignment
pub const ALIGN_4_BYTES: AllocAlignment
pub const ALIGN_8_BYTES: AllocAlignment
Sourcepub const fn new(pow: u8) -> Result<AllocAlignment, ZLayoutError>
pub const fn new(pow: u8) -> Result<AllocAlignment, ZLayoutError>
Try to create a new AllocAlignment from alignment representation in powers of 2.
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
§Errors
This function will return an error if provided alignment power cannot fit into usize.
Sourcepub const fn for_val<T>(_: &T) -> AllocAlignment
pub const fn for_val<T>(_: &T) -> AllocAlignment
Create a new AllocAlignment for value type
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Sourcepub const fn for_type<T>() -> AllocAlignment
pub const fn for_type<T>() -> AllocAlignment
Create a new AllocAlignment for type
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Sourcepub fn get_alignment_value(&self) -> NonZero<usize>
pub fn get_alignment_value(&self) -> NonZero<usize>
Get alignment in normal units (bytes)
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Sourcepub fn align_size(&self, size: NonZero<usize>) -> NonZero<usize>
pub fn align_size(&self, size: NonZero<usize>) -> NonZero<usize>
Align size according to inner alignment.
This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
This call may extend the size (see the example)
# Examples
use zenoh_shm::api::provider::types::AllocAlignment;
let alignment = AllocAlignment::new(2).unwrap(); // 4-byte alignment
let initial_size = 7.try_into().unwrap();
let aligned_size = alignment.align_size(initial_size);
assert_eq!(aligned_size.get(), 8);
Trait Implementations§
Source§impl Clone for AllocAlignment
impl Clone for AllocAlignment
Source§fn clone(&self) -> AllocAlignment
fn clone(&self) -> AllocAlignment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for AllocAlignment
impl Debug for AllocAlignment
Source§impl Default for AllocAlignment
impl Default for AllocAlignment
Source§fn default() -> AllocAlignment
fn default() -> AllocAlignment
Returns the “default value” for a type. Read more
Source§impl Display for AllocAlignment
impl Display for AllocAlignment
Source§impl Ord for AllocAlignment
impl Ord for AllocAlignment
Source§fn cmp(&self, other: &AllocAlignment) -> Ordering
fn cmp(&self, other: &AllocAlignment) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for AllocAlignment
impl PartialEq for AllocAlignment
Source§impl PartialOrd for AllocAlignment
impl PartialOrd for AllocAlignment
impl Copy for AllocAlignment
impl Eq for AllocAlignment
impl StructuralPartialEq for AllocAlignment
Auto Trait Implementations§
impl Freeze for AllocAlignment
impl RefUnwindSafe for AllocAlignment
impl Send for AllocAlignment
impl Sync for AllocAlignment
impl Unpin for AllocAlignment
impl UnwindSafe for AllocAlignment
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more