Struct actix_web::HttpContext
source · pub struct HttpContext<A, S = ()>where
A: Actor<Context = HttpContext<A, S>>,{ /* private fields */ }
Expand description
Execution context for http actors
Implementations
sourceimpl<A, S: 'static> HttpContext<A, S>where
A: Actor<Context = Self>,
impl<A, S: 'static> HttpContext<A, S>where
A: Actor<Context = Self>,
sourcepub fn create(req: HttpRequest<S>, actor: A) -> Body
pub fn create(req: HttpRequest<S>, actor: A) -> Body
Create a new HTTP Context from a request and an actor
sourcepub fn with_factory<F>(req: HttpRequest<S>, f: F) -> Bodywhere
F: FnOnce(&mut Self) -> A + 'static,
pub fn with_factory<F>(req: HttpRequest<S>, f: F) -> Bodywhere
F: FnOnce(&mut Self) -> A + 'static,
Create a new HTTP Context
sourceimpl<A, S> HttpContext<A, S>where
A: Actor<Context = Self>,
impl<A, S> HttpContext<A, S>where
A: Actor<Context = Self>,
sourcepub fn request(&mut self) -> &mut HttpRequest<S>
pub fn request(&mut self) -> &mut HttpRequest<S>
Incoming request
sourcepub fn write_eof(&mut self)
pub fn write_eof(&mut self)
Indicate end of streaming payload. Also this method calls Self::close
.
sourcepub fn handle(&self) -> SpawnHandle
pub fn handle(&self) -> SpawnHandle
Handle of the running future
SpawnHandle is the handle returned by AsyncContext::spawn()
method.
Trait Implementations
sourceimpl<A, S> ActorContext for HttpContext<A, S>where
A: Actor<Context = Self>,
impl<A, S> ActorContext for HttpContext<A, S>where
A: Actor<Context = Self>,
sourceimpl<A, S> AsyncContext<A> for HttpContext<A, S>where
A: Actor<Context = Self>,
impl<A, S> AsyncContext<A> for HttpContext<A, S>where
A: Actor<Context = Self>,
sourcefn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
fn spawn<F>(&mut self, fut: F) -> SpawnHandlewhere
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn async future into context. Returns handle of the item,
could be used for cancelling execution. Read more
sourcefn wait<F>(&mut self, fut: F)where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
fn wait<F>(&mut self, fut: F)where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn future into the context. Stop processing any of incoming events
until this future resolves. Read more
sourcefn cancel_future(&mut self, handle: SpawnHandle) -> bool
fn cancel_future(&mut self, handle: SpawnHandle) -> bool
Cancel future. handle is a value returned by
spawn
method.sourcefn waiting(&self) -> bool
fn waiting(&self) -> bool
Check if context is paused (waiting for future completion or stopping)
sourcefn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandlewhere
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
This method register stream to an actor context and
allows to handle
Stream
in similar way as normal actor messages. Read moresourcefn add_message_stream<S>(&mut self, fut: S)where
S: 'static + Stream<Error = ()>,
<S as Stream>::Item: Message,
A: Handler<<S as Stream>::Item>,
fn add_message_stream<S>(&mut self, fut: S)where
S: 'static + Stream<Error = ()>,
<S as Stream>::Item: Message,
A: Handler<<S as Stream>::Item>,
This method is similar to
add_stream
but it skips stream errors. Read moresourcefn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: 'static + Message,
fn notify<M>(&mut self, msg: M)where
A: Handler<M>,
M: 'static + Message,
Send message
msg
to self.sourcefn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: 'static + Message,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandlewhere
A: Handler<M>,
M: 'static + Message,
Send message
msg
to self after specified period of time. Returns
spawn handle which could be used for cancellation. Notification get
cancelled if context’s stop method get called. Read moresourcefn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnOnce(&mut A, &mut <A as Actor>::Context),
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnOnce(&mut A, &mut <A as Actor>::Context),
Execute closure after specified period of time within same Actor and
Context. Execution get cancelled if context’s stop method get
called. Read more
sourcefn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandlewhere
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
Spawns a job to execute the given closure periodically, at a specified
fixed interval Read more
sourceimpl<A, S> AsyncContextParts<A> for HttpContext<A, S>where
A: Actor<Context = Self>,
impl<A, S> AsyncContextParts<A> for HttpContext<A, S>where
A: Actor<Context = Self>,
fn parts(&mut self) -> &mut ContextParts<A>
Auto Trait Implementations
impl<A, S = ()> !RefUnwindSafe for HttpContext<A, S>
impl<A, S = ()> !Send for HttpContext<A, S>
impl<A, S = ()> !Sync for HttpContext<A, S>
impl<A, S> Unpin for HttpContext<A, S>
impl<A, S = ()> !UnwindSafe for HttpContext<A, S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more