[][src]Trait market::Producer

pub trait Producer {
    type Good;
    type Error;
    fn produce(
        &self,
        good: Self::Good
    ) -> Result<Option<Self::Good>, Self::Error>; fn produce_all(
        &self,
        goods: Vec<Self::Good>
    ) -> Result<Vec<Self::Good>, Self::Error> { ... }
fn force(&self, good: Self::Good) -> Result<(), Self::Error> { ... } }

Produces goods by adding them to the stock of a market.

Associated Types

type Good

The item being produced.

type Error

The error when Self is not functional.

This can be caused by one of the following:

  1. Self is in an invalid state
  2. the market has no functional consumers
Loading content...

Required methods

fn produce(&self, good: Self::Good) -> Result<Option<Self::Good>, Self::Error>

Attempts to add good to the market without blocking.

Returns Some(good) if self desired to add it to its stock but the stock was full. Otherwise returns None.

Errors

An error indicates self is not functional.

Loading content...

Provided methods

fn produce_all(
    &self,
    goods: Vec<Self::Good>
) -> Result<Vec<Self::Good>, Self::Error>

Attempts to add each good in goods to the market without blocking.

Returns the goods that self desired to add to its stock but the stock was full.

Errors

An error indicates self is not functional.

fn force(&self, good: Self::Good) -> Result<(), Self::Error>

Adds good to the market, blocking if needed.

Errors

An error indicates self is not functional.

Loading content...

Implementors

impl<G> Producer for CrossbeamProducer<G>[src]

type Good = G

type Error = ClosedMarketError

impl<G> Producer for PermanentQueue<G>[src]

type Good = G

type Error = NeverErr

impl<G> Producer for UnlimitedQueue<G>[src]

type Good = G

type Error = ClosedMarketError

impl<G, P> Producer for StrippingProducer<G, P> where
    P: Producer,
    <P as Producer>::Good: StripFrom<G> + Clone + Debug,
    <P as Producer>::Error: Debug
[src]

type Good = G

type Error = StripError<<P as Producer>::Error>

impl<P, I> Producer for ApprovedProducer<P, I> where
    P: Producer,
    I: Inspector<Good = <P as Producer>::Good>, 
[src]

type Good = <P as Producer>::Good

type Error = <P as Producer>::Error

impl<W> Producer for ByteWriter<W> where
    W: Write
[src]

type Good = u8

type Error = Error

Loading content...