pub struct PendingClientCtx(/* private fields */);Expand description
a partly initialized client context
Implementations§
Source§impl PendingClientCtx
impl PendingClientCtx
Sourcepub fn step(
self,
token: &[u8],
) -> Result<Step<(ClientCtx, Option<impl Deref<Target = [u8]>>), (PendingClientCtx, impl Deref<Target = [u8]>)>>
pub fn step( self, token: &[u8], ) -> Result<Step<(ClientCtx, Option<impl Deref<Target = [u8]>>), (PendingClientCtx, impl Deref<Target = [u8]>)>>
Feed the server provided token to the client context, performing one step of the initialization. If the initialization is complete then return the established context and optionally a final token that must be sent to the server, otherwise return the pending context and another token to pass to the server.
Examples found in repository?
examples/auth.rs (line 48)
39fn client(spn: &str, input: mpsc::Receiver<Msg>, output: mpsc::Sender<Msg>) {
40 let (mut client, token) =
41 ClientCtx::new(InitiateFlags::empty(), None, spn, None).expect("new");
42 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
43 let mut client = loop {
44 let token = match input.recv().expect("expected data") {
45 Msg::Msg(_) => panic!("client not finished initializing"),
46 Msg::Token(t) => t,
47 };
48 match client.step(&*token).expect("step") {
49 Step::Finished((ctx, token)) => {
50 if let Some(token) = token {
51 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
52 }
53 break ctx
54 },
55 Step::Continue((ctx, token)) => {
56 output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
57 client = ctx;
58 }
59 }
60 };
61 let msg = client.wrap(true, b"super secret message").expect("wrap");
62 output.send(Msg::Msg(Bytes::copy_from_slice(&*msg))).expect("send");
63}Auto Trait Implementations§
impl Freeze for PendingClientCtx
impl RefUnwindSafe for PendingClientCtx
impl Send for PendingClientCtx
impl Sync for PendingClientCtx
impl Unpin for PendingClientCtx
impl UnwindSafe for PendingClientCtx
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