Struct lmdb_zero::Unaligned [] [src]

#[repr(packed)]
pub struct Unaligned<T: LmdbRawIfUnaligned>(_);

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.

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

Example

use lmdb_zero as lmdb;
use lmdb_zero::Unaligned as U;

fn get_a_u64(env: &lmdb::Environment, db: &lmdb::Database,
             key: &str) -> u64 {
  let tx = lmdb::ReadTransaction::new(env).unwrap();
  let access = tx.access();
  access.get::<str, U<u64>>(db, key).unwrap().get()
}

Methods

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

[src]

Wraps t in an Unaligned marker.

Important traits for &'a mut W
[src]

Returns t as if it were wrapped by Unaligned.

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

Important traits for &'a mut W
[src]

Returns t as if it were wrapped by Unaligned.

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

[src]

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.

[src]

Replaces the contained value.

Trait Implementations

impl<T: LmdbRawIfUnaligned> Clone for Unaligned<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: LmdbRawIfUnaligned> Copy for Unaligned<T>
[src]

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

[src]

Returns the name of this type to report in error messages. Read more

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

[src]

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

[src]

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

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter. Read more

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

[src]

Formats the value using the given formatter. Read more

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter.

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

[src]

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

1.0.0
[src]

This method tests for !=.

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

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

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

[src]

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

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

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

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

The resulting type after applying the + operator.

[src]

Performs the + operation.

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

The resulting type after applying the & operator.

[src]

Performs the & operation.

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

The resulting type after applying the | operator.

[src]

Performs the | operation.

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

The resulting type after applying the ^ operator.

[src]

Performs the ^ operation.

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

The resulting type after applying the / operator.

[src]

Performs the / operation.

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

The resulting type after applying the * operator.

[src]

Performs the * operation.

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

The resulting type after applying the % operator.

[src]

Performs the % operation.

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

The resulting type after applying the << operator.

[src]

Performs the << operation.

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

The resulting type after applying the >> operator.

[src]

Performs the >> operation.

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

The resulting type after applying the - operator.

[src]

Performs the - operation.

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

[src]

Performs the += operation.

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

[src]

Performs the &= operation.

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

[src]

Performs the |= operation.

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

[src]

Performs the ^= operation.

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

[src]

Performs the /= operation.

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

[src]

Performs the *= operation.

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

[src]

Performs the %= operation.

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

[src]

Performs the <<= operation.

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

[src]

Performs the >>= operation.

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

[src]

Performs the -= operation.

Auto Trait Implementations

impl<T> Send for Unaligned<T> where
    T: Send

impl<T> Sync for Unaligned<T> where
    T: Sync