Skip to main content

PendingClientCtx

Struct PendingClientCtx 

Source
pub struct PendingClientCtx(/* private fields */);
Expand description

a partly initialized client context

Implementations§

Source§

impl PendingClientCtx

Source

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 61)
52fn client(spn: &str, input: mpsc::Receiver<Msg>, output: mpsc::Sender<Msg>) {
53    let (mut client, token) =
54        ClientCtx::new(InitiateFlags::empty(), None, spn, None).expect("new");
55    output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
56    let mut client = loop {
57        let token = match input.recv().expect("expected data") {
58            Msg::Msg(_) => panic!("client not finished initializing"),
59            Msg::Token(t) => t,
60        };
61        match client.step(&*token).expect("step") {
62            Step::Finished((ctx, token)) => {
63                if let Some(token) = token {
64                    output
65                        .send(Msg::Token(Bytes::copy_from_slice(&*token)))
66                        .expect("send");
67                }
68                break ctx;
69            }
70            Step::Continue((ctx, token)) => {
71                output.send(Msg::Token(Bytes::copy_from_slice(&*token))).expect("send");
72                client = ctx;
73            }
74        }
75    };
76    let msg = client.wrap(true, b"super secret message").expect("wrap");
77    output.send(Msg::Msg(Bytes::copy_from_slice(&*msg))).expect("send");
78}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.