Struct lmdb_zero::Unaligned [] [src]

pub struct Unaligned<T: LmdbRaw>(_);

Wrapper for arbitrary Copy types which lifts their alignment restrictions.

This allows using values which have non-byte alignment but are otherwise LMDB-safe (as defined by LmdbRaw) to be used with it. It obviously does not make T itself packed, so the same discussion with respect to padding in the LmdbRaw documentation applies here as well.

If you are willing to constrain yourself to architectures with lax alignment, such as AMD64/x86, you can instead use the lax_alignment feature to remove LmdbRaw's alignment test.

There is no way to get a reference to the contained value, as Rust currently has no way to express that the reference may be misaligned. (See also https://github.com/rust-lang/rust/issues/27060.)

Methods

impl<T: LmdbRaw> Unaligned<T>
[src]

fn new(t: T) -> Self

Wraps t in an Unaligned marker.

fn of_ref(t: &T) -> &Self

Returns t as if it were wrapped by Unaligned.

This is safe because any &T is a valid &Unaligned<T>.

fn of_mut(t: &mut T) -> &mut Self

Returns t as if it were wrapped by Unaligned.

This is safe because any &T is a valid &Unaligned<T>.

fn get(&self) -> T

Extracts the contained value.

This is safe as the compiler has visibility into the fact that the contained value is misaligned and can copy appropriately.

fn set(&mut self, t: T)

Replaces the contained value.

Trait Implementations

impl<T: Copy + LmdbRaw> Copy for Unaligned<T>
[src]

impl<T: Clone + LmdbRaw> Clone for Unaligned<T>
[src]

fn clone(&self) -> Unaligned<T>

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl<T: LmdbRaw> LmdbRaw for Unaligned<T>
[src]

impl<T: LmdbRaw + LmdbOrdKey> LmdbOrdKey for Unaligned<T>
[src]

fn ordered_by_bytes() -> bool

Returns whether the default LMDB byte-by-byte comparison is correct for valid values of this type. Read more

fn ordered_as_integer() -> bool

Returns whether LMDB will correctly handle this value with the INTEGERKEY or INTEGERDUP flags. Read more

impl<T: LmdbRaw> Binary for Unaligned<T> where T: Binary
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> Debug for Unaligned<T> where T: Debug
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> Display for Unaligned<T> where T: Display
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> LowerExp for Unaligned<T> where T: LowerExp
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> LowerHex for Unaligned<T> where T: LowerHex
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> Octal for Unaligned<T> where T: Octal
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> Pointer for Unaligned<T> where T: Pointer
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> UpperExp for Unaligned<T> where T: UpperExp
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw> UpperHex for Unaligned<T> where T: UpperHex
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl<T: LmdbRaw + PartialEq<T>> PartialEq<Unaligned<T>> for Unaligned<T>
[src]

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

impl<T: LmdbRaw + Eq> Eq for Unaligned<T>
[src]

impl<T: LmdbRaw + PartialOrd<T>> PartialOrd<Unaligned<T>> for Unaligned<T>
[src]

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Self) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Self) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Self) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Self) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T: LmdbRaw + Ord> Ord for Unaligned<T>
[src]

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more

impl<T: LmdbRaw + Hash> Hash for Unaligned<T>
[src]

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl<T: LmdbRaw + Add<T>> Add<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the + operator

fn add(self, rhs: Self) -> Self::Output

The method for the + operator

impl<T: LmdbRaw + BitAnd<T>> BitAnd<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the & operator

fn bitand(self, rhs: Self) -> Self::Output

The method for the & operator

impl<T: LmdbRaw + BitOr<T>> BitOr<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the | operator

fn bitor(self, rhs: Self) -> Self::Output

The method for the | operator

impl<T: LmdbRaw + BitXor<T>> BitXor<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the ^ operator

fn bitxor(self, rhs: Self) -> Self::Output

The method for the ^ operator

impl<T: LmdbRaw + Div<T>> Div<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the / operator

fn div(self, rhs: Self) -> Self::Output

The method for the / operator

impl<T: LmdbRaw + Mul<T>> Mul<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the * operator

fn mul(self, rhs: Self) -> Self::Output

The method for the * operator

impl<T: LmdbRaw + Rem<T>> Rem<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the % operator

fn rem(self, rhs: Self) -> Self::Output

The method for the % operator

impl<T: LmdbRaw + Shl<T>> Shl<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the << operator

fn shl(self, rhs: Self) -> Self::Output

The method for the << operator

impl<T: LmdbRaw + Shr<T>> Shr<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the >> operator

fn shr(self, rhs: Self) -> Self::Output

The method for the >> operator

impl<T: LmdbRaw + Sub<T>> Sub<Unaligned<T>> for Unaligned<T> where T::Output: LmdbRaw
[src]

type Output = Unaligned<T::Output>

The resulting type after applying the - operator

fn sub(self, rhs: Self) -> Self::Output

The method for the - operator

impl<T: LmdbRaw + AddAssign<T>> AddAssign<Unaligned<T>> for Unaligned<T>
[src]

fn add_assign(&mut self, rhs: Self)

The method for the += operator

impl<T: LmdbRaw + BitAndAssign<T>> BitAndAssign<Unaligned<T>> for Unaligned<T>
[src]

fn bitand_assign(&mut self, rhs: Self)

The method for the & operator

impl<T: LmdbRaw + BitOrAssign<T>> BitOrAssign<Unaligned<T>> for Unaligned<T>
[src]

fn bitor_assign(&mut self, rhs: Self)

The method for the |= operator

impl<T: LmdbRaw + BitXorAssign<T>> BitXorAssign<Unaligned<T>> for Unaligned<T>
[src]

fn bitxor_assign(&mut self, rhs: Self)

The method for the ^= operator

impl<T: LmdbRaw + DivAssign<T>> DivAssign<Unaligned<T>> for Unaligned<T>
[src]

fn div_assign(&mut self, rhs: Self)

The method for the /= operator

impl<T: LmdbRaw + MulAssign<T>> MulAssign<Unaligned<T>> for Unaligned<T>
[src]

fn mul_assign(&mut self, rhs: Self)

The method for the *= operator

impl<T: LmdbRaw + RemAssign<T>> RemAssign<Unaligned<T>> for Unaligned<T>
[src]

fn rem_assign(&mut self, rhs: Self)

The method for the %= operator

impl<T: LmdbRaw + ShlAssign<T>> ShlAssign<Unaligned<T>> for Unaligned<T>
[src]

fn shl_assign(&mut self, rhs: Self)

The method for the <<= operator

impl<T: LmdbRaw + ShrAssign<T>> ShrAssign<Unaligned<T>> for Unaligned<T>
[src]

fn shr_assign(&mut self, rhs: Self)

The method for the >>= operator

impl<T: LmdbRaw + SubAssign<T>> SubAssign<Unaligned<T>> for Unaligned<T>
[src]

fn sub_assign(&mut self, rhs: Self)

The method for the -= operator