1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use primitives::registrar::{BoundClient, ClientUrl, Registrar, RegistrarError, PreGrant};
use primitives::scope::Scope;
use super::super::actix::{Handler, Message};
use super::super::AsActor;
#[derive(Clone, Debug)]
pub struct BoundRedirect {
pub bound: ClientUrl<'static>,
}
impl Message for BoundRedirect {
type Result = Result<BoundClient<'static>, RegistrarError>;
}
#[derive(Clone, Debug)]
pub struct Negotiate {
pub client: BoundClient<'static>,
pub scope: Option<Scope>
}
impl Message for Negotiate {
type Result = Result<PreGrant, RegistrarError>;
}
#[derive(Clone, Debug)]
pub struct Check {
pub client: String,
pub passphrase: Option<Vec<u8>>,
}
impl Message for Check {
type Result = Result<(), RegistrarError>;
}
impl<R: Registrar + 'static> Handler<BoundRedirect> for AsActor<R> {
type Result = Result<BoundClient<'static>, RegistrarError>;
fn handle(&mut self, msg: BoundRedirect, _: &mut Self::Context) -> Self::Result {
self.0.bound_redirect(msg.bound)
}
}
impl<R: Registrar + 'static> Handler<Negotiate> for AsActor<R> {
type Result = Result<PreGrant, RegistrarError>;
fn handle(&mut self, msg: Negotiate, _: &mut Self::Context) -> Self::Result {
self.0.negotiate(msg.client, msg.scope)
}
}
impl<R: Registrar + 'static> Handler<Check> for AsActor<R> {
type Result = Result<(), RegistrarError>;
fn handle(&mut self, msg: Check, _: &mut Self::Context) -> Self::Result {
self.0.check(&msg.client, msg.passphrase.as_ref().map(Vec::as_slice))
}
}