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 28)
21fn server(spn: String, input: mpsc::Receiver<Msg>, output: mpsc::Sender<Msg>) {
22 let mut server = ServerCtx::new(AcceptFlags::empty(), Some(&spn), None).expect("new");
23 let mut server = loop {
24 let token = match input.recv().expect("expected data") {
25 Msg::Msg(_) => panic!("server not finished initializing"),
26 Msg::Token(t) => t,
27 };
28 match server.step(&*token).expect("step") {
29 Step::Finished((ctx, token)) => {
30 if let Some(token) = token {
31 output
32 .send(Msg::Token(Bytes::copy_from_slice(&*token)))
33 .expect("send");
34 }
35 break ctx;
36 }
37 Step::Continue((ctx, token)) => {
38 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
39 server = ctx;
40 }
41 }
42 };
43 match input.recv().expect("expected data msg") {
44 Msg::Token(_) => panic!("unexpected extra token"),
45 Msg::Msg(secret_msg) => println!(
46 "{}",
47 String::from_utf8_lossy(&server.unwrap(&*secret_msg).expect("unwrap"))
48 ),
49 }
50}Auto Trait Implementations§
impl Freeze for PendingServerCtx
impl RefUnwindSafe for PendingServerCtx
impl Send for PendingServerCtx
impl !Sync for PendingServerCtx
impl Unpin for PendingServerCtx
impl UnsafeUnpin 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