pub struct ClientHandshake { /* private fields */ }Expand description
Client (app) side of the handshake, between the challenge and the server proof
The dev runtime calls start, sends the returned
challenge as a WebSocket text message, waits for the server’s text reply,
and passes it to finish. Only after finish succeeds
does the app send its proof and then anything identifying the process.
§Example
use whisker_dev_protocol::{ClientHandshake, Error, ServerHandshake};
let (client, challenge) = ClientHandshake::start("app secret")?;
// A server from another session holds a different secret.
let (_server, proof) = ServerHandshake::respond("other secret", &challenge)?;
assert!(matches!(client.finish(&proof), Err(Error::InvalidServerProof)));Implementations§
Source§impl ClientHandshake
impl ClientHandshake
Sourcepub fn start(secret: &str) -> Result<(Self, String), Error>
pub fn start(secret: &str) -> Result<(Self, String), Error>
Begin a handshake and return the challenge text to send
Fails with Error::MissingSecret for an empty secret and with
Error::Random if no nonce can be generated.
Sourcepub fn finish(self, server_proof: &str) -> Result<(Session, String), Error>
pub fn finish(self, server_proof: &str) -> Result<(Session, String), Error>
Verify the server’s proof and return the session plus the client proof to send
Fails with Error::InvalidServerProof when the server does not hold
the same secret, which is what an app left over from a previous
whisker run session observes.
Auto Trait Implementations§
impl Forget for ClientHandshake
impl Freeze for ClientHandshake
impl Move for ClientHandshake
impl RefUnwindSafe for ClientHandshake
impl Send for ClientHandshake
impl Sync for ClientHandshake
impl Unpin for ClientHandshake
impl UnsafeUnpin for ClientHandshake
impl UnwindSafe for ClientHandshake
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