pub struct PendingServerCtx(/* private fields */);Implementations§
Source§impl PendingServerCtx
impl PendingServerCtx
Sourcepub fn step(
self,
token: &[u8],
) -> Result<Step<(ServerCtx, Option<impl Deref<Target = [u8]>>), (PendingServerCtx, impl Deref<Target = [u8]>)>>
pub fn step( self, token: &[u8], ) -> Result<Step<(ServerCtx, Option<impl Deref<Target = [u8]>>), (PendingServerCtx, impl Deref<Target = [u8]>)>>
Examples found in repository?
examples/auth.rs (line 17)
10fn server(spn: String, input: mpsc::Receiver<Msg>, output: mpsc::Sender<Msg>) {
11 let mut server = ServerCtx::new(AcceptFlags::empty(), Some(&spn)).expect("new");
12 let mut server = loop {
13 let token = match input.recv().expect("expected data") {
14 Msg::Msg(_) => panic!("server not finished initializing"),
15 Msg::Token(t) => t,
16 };
17 match server.step(&*token).expect("step") {
18 Step::Finished((ctx, token)) => {
19 if let Some(token) = token {
20 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
21 }
22 break ctx
23 },
24 Step::Continue((ctx, token)) => {
25 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
26 server = ctx;
27 }
28 }
29 };
30 match input.recv().expect("expected data msg") {
31 Msg::Token(_) => panic!("unexpected extra token"),
32 Msg::Msg(secret_msg) => println!(
33 "{}",
34 String::from_utf8_lossy(&server.unwrap(&*secret_msg).expect("unwrap"))
35 ),
36 }
37}Auto Trait Implementations§
impl Freeze for PendingServerCtx
impl RefUnwindSafe for PendingServerCtx
impl Send for PendingServerCtx
impl Sync for PendingServerCtx
impl Unpin for PendingServerCtx
impl UnwindSafe for PendingServerCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more