Struct io_interner::IOInterner[][src]

pub struct IOInterner<T: Write + Read + Seek> {
    pub inner: Mutex<T>,
}

A struct wrapping a Mutex<T> used for storing and retrieving data thought readers.

Note that T it's wrapped into a Mutex for ensure IOObj does not lock access to the IOInterner and to guarantee will only lock at Read methods.

Fields

inner: Mutex<T>

The underlying writer wrapped into a Mutex.

The IOEntry comparison algorithm would mess up if you do not ensure that already allocated data remain equal after releasing a lock,it's advisable to only write at the end.

Implementations

impl<T: Write + Read + Seek> IOInterner<T>[src]

pub fn new(x: T) -> Self[src]

Create a new IOInterner that uses as common storage x.

pub fn flush(&self) -> Result<()>[src]

Invokes Write::flush on self.inner.

Panics

This function panics if the Mutex it's poisoned.

pub fn get_or_intern<U: Read + Seek>(&self, buf: U) -> Result<IOEntry<'_, T>>[src]

Creates a new IOEntry object that will be able to generate IOObj that always read same bytes as buf from T so buf will be written at the end if it's not already.

The IOObj does not implement Write as that would mess up equality of two IOEntry instances pointing to the same position with same length which it's actually the comparison algorithm.

Panics

This function panics if the Mutex it's poisoned.

Auto Trait Implementations

impl<T> RefUnwindSafe for IOInterner<T>[src]

impl<T> Send for IOInterner<T> where
    T: Send
[src]

impl<T> Sync for IOInterner<T> where
    T: Send
[src]

impl<T> Unpin for IOInterner<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for IOInterner<T>[src]

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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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.