[][src]Trait market::Consumer

pub trait Consumer {
    type Good;
    type Fault: Error + 'static;
    fn consume(&self) -> Result<Self::Good, ConsumeFailure<Self::Fault>>;

    fn consume_all(&self) -> Result<Vec<Self::Good>, Self::Fault> { ... }
fn demand(&self) -> Result<Self::Good, Self::Fault> { ... } }

Retrieves goods from a market.

The order in which goods are retrieved is defined by the implementer.

Associated Types

type Good

The item being consumed.

type Fault: Error + 'static

The fault that could be thrown during consumption.

Loading content...

Required methods

fn consume(&self) -> Result<Self::Good, ConsumeFailure<Self::Fault>>

Retrieves the next good from the market without blocking.

To ensure all functionality of a Consumer performs as specified, the implementor MUST implement consume such that all of the following specifications are true:

  1. consume returns without blocking the current process.
  2. If at least one good is in stock, consume returns one of those goods.
  3. If fault T is thrown during consumption, consume throws ConsumeFailure::Fault(T).
  4. If there are no goods in stock, consume throws ConsumeFailure::EmptyStock.
Loading content...

Provided methods

fn consume_all(&self) -> Result<Vec<Self::Good>, Self::Fault>

Retrieves all goods held in the market without blocking.

If the stock of the market is empty, an empty list is returned. If a fault is thrown after consuming 1 or more goods, the consumption stops and the fault is ignored.

fn demand(&self) -> Result<Self::Good, Self::Fault>

Retrieves the next good from the market, blocking until one is available.

Loading content...

Implementors

impl Consumer for Waiter[src]

impl<C, I> Consumer for VigilantConsumer<C, I> where
    C: Consumer,
    I: Inspector<Good = <C as Consumer>::Good> + Debug
[src]

type Good = <C as Consumer>::Good

type Fault = <C as Consumer>::Fault

impl<G> Consumer for CrossbeamConsumer<G> where
    G: Debug
[src]

type Good = G

type Fault = ClosedMarketFault

impl<G> Consumer for StdConsumer<G> where
    G: Debug
[src]

type Good = G

type Fault = ClosedMarketFault

impl<G> Consumer for Reader<G> where
    G: AssembleFrom<u8> + Debug + 'static,
    <G as AssembleFrom<u8>>::Error: 'static, 
[src]

type Good = G

type Fault = ReadError<G>

impl<G> Consumer for PermanentQueue<G> where
    G: Debug
[src]

type Good = G

type Fault = Never

impl<G> Consumer for UnlimitedQueue<G> where
    G: Debug
[src]

type Good = G

type Fault = ClosedMarketFault

impl<G, T> Consumer for Collector<G, T> where
    T: Error + 'static, 
[src]

type Good = G

type Fault = T

impl<I, O, E> Consumer for Process<I, O, E> where
    O: AssembleFrom<u8> + Debug + 'static,
    <O as AssembleFrom<u8>>::Error: 'static, 
[src]

type Good = O

type Fault = <Reader<O> as Consumer>::Fault

impl<O, E> Consumer for Thread<O, E> where
    E: Error + 'static,
    O: Debug
[src]

type Good = O

type Fault = Fault<E>

Loading content...