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

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()
}

Implementations

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

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Formats the value using the given formatter.

The resulting type after applying the & operator.

Performs the & operation. Read more

Performs the &= operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Performs the |= operation. Read more

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Performs the ^= operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Feeds this value into the given Hasher. Read more

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

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

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

Formats the value using the given formatter.

Formats the value using the given formatter.

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Formats the value using the given formatter.

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

Formats the value using the given formatter.

The resulting type after applying the % operator.

Performs the % operation. Read more

Performs the %= operation. Read more

The resulting type after applying the << operator.

Performs the << operation. Read more

Performs the <<= operation. Read more

The resulting type after applying the >> operator.

Performs the >> operation. Read more

Performs the >>= operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Formats the value using the given formatter.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Casts the given reference to a byte slice appropriate for storage in LMDB. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Clone this value, and then immediately put it into a Box behind a trait object of this trait. Read more

Returns the address of self. Read more

Returns the argument unchanged.

Given a byte slice, return an instance of Self described, or Err with an error message if the given byte slice is not an appropriate value. Read more

Given a mutable byte slice containing arbitrary data, return an instance of Self. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Like LmdbOrdKey::ordered_by_bytes()

Like LmdbOrdKey::ordered_as_integer()

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

Clone this value, and then immediately put it into a Box behind a trait object of this trait. Read more

Returns the address of self. Read more

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.