Struct persistent::Read [] [src]

pub struct Read<P: Key> {
    // some fields omitted
}

Middleware for data that persists between Requests with read-only capabilities.

The data is stored behind an Arc, so multiple threads can have concurrent, non-blocking access.

Read can be linked as BeforeMiddleware to add data to the Request extensions and it can be linked as an AfterMiddleware to add data to the Response extensions.

Read also implements Plugin, so the data stored within can be accessed through request.get::<Read<P>>() as an Arc<P::Value>.

Methods

impl<P: Key> Read<P> where P::Value: Send + Sync

fn both(start: P::Value) -> (Read<P>, Read<P>)

Construct a new pair of Read that can be passed directly to Chain::link.

The data is initialized with the passed-in value.

fn one(start: P::Value) -> Read<P>

Construct a new Read that can be passed directly to Chain::link_before or Chain::link_after.

The data is initialized with the passed-in value.

Trait Implementations

impl<P: Key> Clone for Read<P> where P::Value: Send + Sync

fn clone(&self) -> Read<P>

fn clone_from(&mut self, source: &Self)

impl<P: Key> Key for Read<P> where P::Value: 'static

type Value = Arc<P::Value>

impl<'a, 'b, P: Key> Plugin<Request<'a, 'b>> for Read<P> where P::Value: Send + Sync

type Error = PersistentError

fn eval(req: &mut Request<'a, 'b>) -> Result<Arc<P::Value>, PersistentError>

impl<P: Key> BeforeMiddleware for Read<P> where P::Value: Send + Sync

fn before(&self, req: &mut Request) -> IronResult<()>

fn catch(&self, &mut Request, err: IronError) -> Result<(), IronError>

impl<P: Key> AfterMiddleware for Read<P> where P::Value: Send + Sync

fn after(&self, _: &mut Request, res: Response) -> IronResult<Response>

fn catch(&self, &mut Request, err: IronError) -> Result<Response, IronError>