pub struct OptId64<T>(/* private fields */);Expand description
Optional 64-bit ID with the same 8-byte representation as Id64.
Zero ([0u8; 8]) is interpreted as None. Use in zerocopy-compatible
structs where Option<Id64> would break alignment (16+ bytes).
ⓘ
#[derive(FromBytes, IntoBytes, Immutable, KnownLayout, Copy, Clone)]
#[repr(C)]
struct Follower {
follow: Id64<H>, // 8 bytes
follower: OptId64<H>, // 8 bytes, zero = None
}Implementations§
Source§impl<T> OptId64<T>
impl<T> OptId64<T>
pub const NONE: Self
pub fn some(id: Id64<T>) -> Self
pub fn get(self) -> Option<Id64<T>>
pub fn is_some(self) -> bool
pub fn is_none(self) -> bool
Sourcepub fn from_bytes(bytes: [u8; 8]) -> Self
pub fn from_bytes(bytes: [u8; 8]) -> Self
from BE bytes
pub fn to_be_bytes(self) -> [u8; 8]
pub fn from_be_bytes(bytes: [u8; 8]) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OptId64<()>
Available on crate feature std only.
impl<'de> Deserialize<'de> for OptId64<()>
Available on crate feature
std only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'de, T: IdHasher> Deserialize<'de> for OptId64<T>
Available on crate feature std only.
impl<'de, T: IdHasher> Deserialize<'de> for OptId64<T>
Available on crate feature
std only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> FromBytes for OptId64<T>
impl<T> FromBytes for OptId64<T>
Source§fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
Source§fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
Source§fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
Interprets the suffix of the given bytes as a
&Self. Read moreSource§fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§impl<T> IntoBytes for OptId64<T>
impl<T> IntoBytes for OptId64<T>
Source§fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
Gets the bytes of this value mutably. Read more
Source§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl<T> KnownLayout for OptId64<T>where
Self: Sized,
impl<T> KnownLayout for OptId64<T>where
Self: Sized,
Source§type PointerMetadata = ()
type PointerMetadata = ()
The type of metadata stored in a pointer to
Self. Read moreSource§fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
Computes the size of an object of type
Self with the given pointer
metadata. Read moreSource§impl<T> Ord for OptId64<T>
impl<T> Ord for OptId64<T>
Source§impl<T> PartialOrd for OptId64<T>
impl<T> PartialOrd for OptId64<T>
Source§impl Rapira for OptId64<()>
impl Rapira for OptId64<()>
const STATIC_SIZE: Option<usize>
const MIN_SIZE: usize = 8
Source§fn check_bytes(slice: &mut &[u8]) -> Result<(), RapiraError>where
Self: Sized,
fn check_bytes(slice: &mut &[u8]) -> Result<(), RapiraError>where
Self: Sized,
check bytes, collections len, check utf-8, NonZero, f32 and others…
Source§fn from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
this is safe, but not check collections capacity!
recommend use only for safe data (example: from DB), not external data.
fn convert_to_bytes(&self, slice: &mut [u8], cursor: &mut usize)
fn debug_from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>
Source§unsafe fn from_slice_unchecked(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
unsafe fn from_slice_unchecked(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
Safety Read more
Source§unsafe fn from_slice_unsafe(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
unsafe fn from_slice_unsafe(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
Safety Read more
Source§fn from_slice_versioned(
slice: &mut &[u8],
_version: u8,
) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice_versioned(
slice: &mut &[u8],
_version: u8,
) -> Result<Self, RapiraError>where
Self: Sized,
Deserialize with schema version awareness. Read more
fn try_convert_to_bytes( &self, slice: &mut [u8], cursor: &mut usize, ) -> Result<(), RapiraError>
Source§fn convert_to_bytes_ctx(
&self,
slice: &mut [u8],
cursor: &mut usize,
_flags: RapiraFlags,
)
fn convert_to_bytes_ctx( &self, slice: &mut [u8], cursor: &mut usize, _flags: RapiraFlags, )
Context-aware serialization. Default: delegates to
convert_to_bytes.Source§fn from_slice_ctx(
slice: &mut &[u8],
_flags: RapiraFlags,
) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice_ctx(
slice: &mut &[u8],
_flags: RapiraFlags,
) -> Result<Self, RapiraError>where
Self: Sized,
Context-aware deserialization. Default: delegates to
from_slice.Source§fn size_ctx(&self, _flags: RapiraFlags) -> usize
fn size_ctx(&self, _flags: RapiraFlags) -> usize
Context-aware size calculation. Default: delegates to
size.Source§impl<T: IdHasher> Rapira for OptId64<T>
impl<T: IdHasher> Rapira for OptId64<T>
const STATIC_SIZE: Option<usize>
const MIN_SIZE: usize = 8
Source§fn check_bytes(slice: &mut &[u8]) -> Result<(), RapiraError>where
Self: Sized,
fn check_bytes(slice: &mut &[u8]) -> Result<(), RapiraError>where
Self: Sized,
check bytes, collections len, check utf-8, NonZero, f32 and others…
Source§fn from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
this is safe, but not check collections capacity!
recommend use only for safe data (example: from DB), not external data.
fn convert_to_bytes(&self, slice: &mut [u8], cursor: &mut usize)
Source§fn convert_to_bytes_ctx(
&self,
slice: &mut [u8],
cursor: &mut usize,
flags: RapiraFlags,
)
fn convert_to_bytes_ctx( &self, slice: &mut [u8], cursor: &mut usize, flags: RapiraFlags, )
Context-aware serialization. Default: delegates to
convert_to_bytes.Source§fn from_slice_ctx(
slice: &mut &[u8],
flags: RapiraFlags,
) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice_ctx(
slice: &mut &[u8],
flags: RapiraFlags,
) -> Result<Self, RapiraError>where
Self: Sized,
Context-aware deserialization. Default: delegates to
from_slice.fn debug_from_slice(slice: &mut &[u8]) -> Result<Self, RapiraError>
Source§unsafe fn from_slice_unchecked(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
unsafe fn from_slice_unchecked(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
Safety Read more
Source§unsafe fn from_slice_unsafe(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
unsafe fn from_slice_unsafe(slice: &mut &[u8]) -> Result<Self, RapiraError>where
Self: Sized,
Safety Read more
Source§fn from_slice_versioned(
slice: &mut &[u8],
_version: u8,
) -> Result<Self, RapiraError>where
Self: Sized,
fn from_slice_versioned(
slice: &mut &[u8],
_version: u8,
) -> Result<Self, RapiraError>where
Self: Sized,
Deserialize with schema version awareness. Read more
fn try_convert_to_bytes( &self, slice: &mut [u8], cursor: &mut usize, ) -> Result<(), RapiraError>
Source§fn size_ctx(&self, _flags: RapiraFlags) -> usize
fn size_ctx(&self, _flags: RapiraFlags) -> usize
Context-aware size calculation. Default: delegates to
size.Source§impl<T> TransparentWrapper<u64_be> for OptId64<T>
impl<T> TransparentWrapper<u64_be> for OptId64<T>
Source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
Convert a reference to the inner type into a reference to the wrapper
type.
Source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
Convert a mutable reference to the inner type into a mutable reference to
the wrapper type.
Source§fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
fn wrap_slice(s: &[Inner]) -> &[Self]where
Self: Sized,
Convert a slice to the inner type into a slice to the wrapper type.
Source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]where
Self: Sized,
Convert a mutable slice to the inner type into a mutable slice to the
wrapper type.
Source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
Convert a reference to the wrapper type into a reference to the inner
type.
Source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
Convert a mutable reference to the wrapper type into a mutable reference
to the inner type.
Source§fn peel_slice(s: &[Self]) -> &[Inner]where
Self: Sized,
fn peel_slice(s: &[Self]) -> &[Inner]where
Self: Sized,
Convert a slice to the wrapped type into a slice to the inner type.
Source§fn peel_slice_mut(s: &mut [Self]) -> &mut [Inner]where
Self: Sized,
fn peel_slice_mut(s: &mut [Self]) -> &mut [Inner]where
Self: Sized,
Convert a mutable slice to the wrapped type into a mutable slice to the
inner type.
Source§impl<T> TryFromBytes for OptId64<T>
impl<T> TryFromBytes for OptId64<T>
Source§fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
impl<T> Copy for OptId64<T>
impl<T> Eq for OptId64<T>
impl<T> Immutable for OptId64<T>
impl<T: 'static> Pod for OptId64<T>
Auto Trait Implementations§
impl<T> Freeze for OptId64<T>
impl<T> RefUnwindSafe for OptId64<T>where
T: RefUnwindSafe,
impl<T> Send for OptId64<T>where
T: Send,
impl<T> Sync for OptId64<T>where
T: Sync,
impl<T> Unpin for OptId64<T>where
T: Unpin,
impl<T> UnsafeUnpin for OptId64<T>
impl<T> UnwindSafe for OptId64<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<I, T> TransparentWrapperAlloc<I> for T
impl<I, T> TransparentWrapperAlloc<I> for T
Source§fn wrap_vec(s: Vec<Inner>) -> Vec<Self>where
Self: Sized,
fn wrap_vec(s: Vec<Inner>) -> Vec<Self>where
Self: Sized,
Convert a vec of the inner type into a vec of the wrapper type.
Source§fn wrap_box(s: Box<Inner>) -> Box<Self>
fn wrap_box(s: Box<Inner>) -> Box<Self>
Convert a box to the inner type into a box to the wrapper
type.
Source§fn wrap_rc(s: Rc<Inner>) -> Rc<Self>
fn wrap_rc(s: Rc<Inner>) -> Rc<Self>
Convert an
Rc to the inner type into an Rc to the wrapper type.Source§fn wrap_arc(s: Arc<Inner>) -> Arc<Self>
fn wrap_arc(s: Arc<Inner>) -> Arc<Self>
Convert an
Arc to the inner type into an Arc to the wrapper type.Source§fn peel_vec(s: Vec<Self>) -> Vec<Inner>where
Self: Sized,
fn peel_vec(s: Vec<Self>) -> Vec<Inner>where
Self: Sized,
Convert a vec of the wrapper type into a vec of the inner type.
Source§fn peel_box(s: Box<Self>) -> Box<Inner>
fn peel_box(s: Box<Self>) -> Box<Inner>
Convert a box to the wrapper type into a box to the inner
type.