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 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§

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.