Trait market::Consumer[][src]

pub trait Consumer {
    type Good;
    type Failure: Failure;
    fn consume(&self) -> Result<Self::Good, Self::Failure>;

    fn goods(&self) -> Goods<'_, Self>

Notable traits for Goods<'_, C>

impl<C: Consumer> Iterator for Goods<'_, C> type Item = Result<<C as Consumer>::Good, <<C as Consumer>::Failure as Failure>::Fault>;

    where
        Self: Sized
, { ... }
fn demand(&self) -> Result<Self::Good, <Self::Failure as Failure>::Fault> { ... } }

Retrieves goods from a market.

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

Associated Types

type Good[src]

The item being consumed.

type Failure: Failure[src]

Describes a failure to successfully complete consumption.

Loading content...

Required methods

fn consume(&self) -> Result<Self::Good, Self::Failure>[src]

Retrieves the next good from the market without blocking.

SHALL only run in the calling process and return the next good in the market without blocking.

Errors

If fault T is caught, SHALL throw Self::Failure F such that F.fault() == Some(T). If self cannot retrieve a good without blocking, SHALL throw an appropriate Self::Failure.

Loading content...

Provided methods

fn goods(&self) -> Goods<'_, Self>

Notable traits for Goods<'_, C>

impl<C: Consumer> Iterator for Goods<'_, C> type Item = Result<<C as Consumer>::Good, <<C as Consumer>::Failure as Failure>::Fault>;
where
    Self: Sized
[src]

Returns a Goods of self.

fn demand(&self) -> Result<Self::Good, <Self::Failure as Failure>::Fault>[src]

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

Errors

If fault T is caught, SHALL throw T.

Loading content...

Implementors

impl Consumer for Hammer[src]

type Good = ()

type Failure = InsufficientStockFailure

impl<G> Consumer for CrossbeamConsumer<G>[src]

type Good = G

type Failure = ConsumeFailure<WithdrawnSupplyFault>

fn consume(&self) -> Result<Self::Good, Self::Failure>[src]

Attempts to retrieve good from a crossbeam channel.

If attempt fails, throws a ConsumeFailure describing the failure. If source of failure is WithdrawnSupplyFault, provides channel description in failure.

impl<G> Consumer for StdConsumer<G>[src]

impl<G> Consumer for Procurer<G>[src]

type Good = G

type Failure = InsufficientStockFailure

impl<G> Consumer for Accepter<G>[src]

type Good = G

type Failure = InsufficientStockFailure

impl<G, T> Consumer for Collector<G, T> where
    T: TryFrom<ConsumeFailure<T>>, 
[src]

type Good = G

type Failure = ConsumeFailure<T>

impl<G: AssembleFrom<u8>> Consumer for Reader<G> where
    <G as AssembleFrom<u8>>::Error: TryFrom<ConsumeFailure<<G as AssembleFrom<u8>>::Error>>, 
[src]

type Good = G

type Failure = ConsumeFailure<ReadFault<G>>

impl<I: DisassembleInto<u8>, O: AssembleFrom<u8>, E: AssembleFrom<u8>> Consumer for Process<I, O, E>[src]

impl<S, E: TryFrom<ConsumeFailure<E>>> Consumer for Thread<S, E>[src]

type Good = S

type Failure = ConsumeFailure<E>

Loading content...