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]

Wraps t in an Unaligned marker.

Returns t as if it were wrapped by Unaligned.

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

Returns t as if it were wrapped by Unaligned.

This is safe because any &T is a valid &Unaligned<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.

Replaces the contained value.

Trait Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

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

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

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

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]

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

Formats the value using the given formatter.

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

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

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]

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

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

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

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

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]

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

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

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

Feeds a slice of this type into the state provided.

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

The resulting type after applying the + operator

The method for the + operator

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

The resulting type after applying the & operator

The method for the & operator

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

The resulting type after applying the | operator

The method for the | operator

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

The resulting type after applying the ^ operator

The method for the ^ operator

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

The resulting type after applying the / operator

The method for the / operator

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

The resulting type after applying the * operator

The method for the * operator

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

The resulting type after applying the % operator

The method for the % operator

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

The resulting type after applying the << operator

The method for the << operator

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

The resulting type after applying the >> operator

The method for the >> operator

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

The resulting type after applying the - operator

The method for the - operator

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

The method for the += operator

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

The method for the &= operator

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

The method for the |= operator

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

The method for the ^= operator

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

The method for the /= operator

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

The method for the *= operator

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

The method for the %= operator

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

The method for the <<= operator

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

The method for the >>= operator

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

The method for the -= operator