Enum bitvec::domain::Domain[][src]

pub enum Domain<'a, T> where
    T: BitStore
{ Enclave { head: BitIdx<T::Mem>, elem: &'a T, tail: BitEnd<T::Mem>, }, Region { head: Option<(BitIdx<T::Mem>, &'a T)>, body: &'a [T::Unalias], tail: Option<(&'a T, BitEnd<T::Mem>)>, }, }

Granular representation of the memory region containing a BitSlice.

BitSlice regions can be described in terms of edge and center partitions, where the edge partitions must retain the aliasing status of the source BitSlice handle, and the center partition is known to be completely unaliased by any other view. This property allows any BitSlice handle to be decomposed into smaller regions, and safely remove any aliasing markers from the center partition that no longer requires such safeguarding.

This enum splits the underlying element slice [T] into the maybe-aliased edge elements and known-unaliased center elements. If you do not need to work with the memory elements directly, and only need to firmly specify the access behavior of the BitSlice handle, use the BitDomain and BitDomainMut enums.

Lifetimes

  • 'a: The lifetime of the referent storage region.

Type Parameters

  • T: The register type of the source BitSlice handle, including any aliasing markers.

Mutability

The immutable view produces T::Alias references, which permit foreign writes to the referent location but disallow writes through itself. The mutable view produces T::Access references, because &mut _ references can only ever be produced when no other aliasing handle exists. The write permissions must be weakened from &mut T::Alias to &T::Access in order to satisfy the Rust memory rules.

The edge references do not forbid modifying bits outside of the source BitSlice domain, and writes out of bounds will be correctly handled by any other handles capable of viewing those elements. Doing so is still incorrect, though defined, and you are responsible for writing only within bounds when using DomainMut.

Variants

Enclave

Indicates that a BitSlice is contained entirely in the interior indices of a single memory element.

Fields of Enclave

head: BitIdx<T::Mem>

The start index of the BitSlice.

elem: &'a T

An aliased view of the element containing the BitSlice.

This is necessary even on immutable views, because other views to the referent element may be permitted to modify it.

tail: BitEnd<T::Mem>

The end index of the BitSlice.

Region

Indicates that a BitSlice region touches at least one edge index of any number of elements.

This contains two optional references to the aliased edges, and one reference to the unaliased middle. Each can be queried and used individually.

Fields of Region

head: Option<(BitIdx<T::Mem>, &'a T)>

If the BitSlice started in the interior of its first element, this contains the starting index and the base address.

body: &'a [T::Unalias]

All fully-spanned, unaliased, elements.

This is marked as bare memory without any access protections, because it is statically impossible for any other handle to have write access to the region it covers. As such, a BitSlice that was marked as entirely aliased, but contains interior unaliased elements, can safely remove its aliasing protections.

tail: Option<(&'a T, BitEnd<T::Mem>)>

If the BitSlice ended in the interior of its last element, this contains the ending index and the last address.

Implementations

impl<'a, T> Domain<'a, T> where
    T: BitStore
[src]

pub fn enclave(self) -> Option<(BitIdx<T::Mem>, &'a T, BitEnd<T::Mem>)>[src]

Attempts to view the domain as an enclave variant.

Parameters

  • self

Returns

If self is the Enclave variant, this returns Some of the enclave fields, as a tuple. Otherwise, it returns None.

pub fn region(
    self
) -> Option<(Option<(BitIdx<T::Mem>, &'a T)>, &'a [T::Unalias], Option<(&'a T, BitEnd<T::Mem>)>)>
[src]

Attempts to view the domain as the region variant.

Parameters

  • self

Returns

If self is the Region variant, this returns Some of the region fields, as a tuple. Otherwise, it returns None.

Trait Implementations

impl<T> Binary for Domain<'_, T> where
    T: BitStore
[src]

impl<T> Clone for Domain<'_, T> where
    T: BitStore
[src]

impl<T> Copy for Domain<'_, T> where
    T: BitStore
[src]

impl<'a, T: Debug> Debug for Domain<'a, T> where
    T: BitStore,
    T::Mem: Debug,
    T::Mem: Debug,
    T::Mem: Debug,
    T::Unalias: Debug,
    T::Mem: Debug
[src]

impl<'a, T> DoubleEndedIterator for Domain<'a, T> where
    T: BitStore
[src]

impl<T> ExactSizeIterator for Domain<'_, T> where
    T: BitStore
[src]

impl<T> FusedIterator for Domain<'_, T> where
    T: BitStore
[src]

impl<'a, T> Iterator for Domain<'a, T> where
    T: BitStore
[src]

type Item = T::Mem

The type of the elements being iterated over.

impl<T> LowerHex for Domain<'_, T> where
    T: BitStore
[src]

impl<T> Octal for Domain<'_, T> where
    T: BitStore
[src]

impl<T> Serialize for Domain<'_, T> where
    T: BitStore,
    T::Mem: Serialize
[src]

impl<T> UpperHex for Domain<'_, T> where
    T: BitStore
[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Domain<'a, T> where
    T: RefUnwindSafe,
    <T as BitStore>::Mem: RefUnwindSafe,
    <T as BitStore>::Unalias: RefUnwindSafe

impl<'a, T> Send for Domain<'a, T> where
    T: Sync,
    <T as BitStore>::Unalias: Sync

impl<'a, T> Sync for Domain<'a, T> where
    T: Sync,
    <T as BitStore>::Unalias: Sync

impl<'a, T> Unpin for Domain<'a, T>

impl<'a, T> UnwindSafe for Domain<'a, T> where
    T: RefUnwindSafe,
    <T as BitStore>::Mem: UnwindSafe,
    <T as BitStore>::Unalias: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T[src]

impl<T> FmtForward for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Pipe for T where
    T: ?Sized
[src]

impl<T> Tap for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.