[−][src]Trait oxide_auth_actix::OAuthOperation
Describes an operation that can be performed in the presence of an Endpoint
This trait can be implemented by any type, but is very useful in Actor scenarios, where an Actor can provide an endpoint to an operation sent as a message.
Here's how any Endpoint type can be turned into an Actor that responds to OAuthMessages:
ⓘThis example is not tested
use actix::{Actor, Context, Handler}; use oxide_auth::endpoint::Endpoint; use oxide_auth_actix::OAuthOperation; pub struct MyEndpoint { // Define your endpoint... } impl Endpoint<OAuthRequest> for MyEndpoint { // Implement your endpoint... } // Implement Actor impl Actor for MyEndpoint { type Context = Context<Self>; } // Handle incoming OAuthMessages impl<Op, Ext> Handler<OAuthMessage<Op, Ext>> for MyEndpoint where Op: OAuthOperation, { type Result = Result<Op::Item, Op::Error>; fn handle(&mut self, msg: OAuthMessage<Op, Ext>, _: &mut Self::Context) -> Self::Result { let (op, _) = msg.into_inner(); op.run(self) } }
By additionally specifying a type for Extras, more advanced patterns can be used
ⓘThis example is not tested
type Ext = Option<MyCustomSolicitor>; // Handle incoming OAuthMessages impl<Op> Handler<OAuthMessage<Op, Ext>> for MyEndpoint where Op: OAuthOperation, { type Result = Result<Op::Item, Op::Error>; fn handle(&mut self, msg: OAuthMessage<Op, Ext>, _: &mut Self::Context) -> Self::Result { let (op, ext) = msg.into_inner(); op.run(self.with_my_custom_solicitor(ext)) } }
Associated Types
type Item: 'static
The success-type produced by an OAuthOperation
type Error: Debug + 'static
The error type produced by an OAuthOperation
Required methods
fn run<E>(self, endpoint: E) -> Result<Self::Item, Self::Error> where
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
Performs the oxide operation with the provided endpoint
Provided methods
fn wrap<Extras>(self, extras: Extras) -> OAuthMessage<Self, Extras>
Turn an OAuthOperation into a Message to send to an actor
Implementors
impl OAuthOperation for Authorize
[src]
type Item = OAuthResponse
type Error = WebError
fn run<E>(self, endpoint: E) -> Result<Self::Item, Self::Error> where
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
[src]
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
impl OAuthOperation for Refresh
[src]
type Item = OAuthResponse
type Error = WebError
fn run<E>(self, endpoint: E) -> Result<Self::Item, Self::Error> where
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
[src]
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
impl OAuthOperation for Resource
[src]
type Item = Grant
type Error = Result<OAuthResponse, WebError>
fn run<E>(self, endpoint: E) -> Result<Self::Item, Self::Error> where
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,
[src]
E: Endpoint<OAuthRequest>,
WebError: From<E::Error>,