Struct Session

Source
pub struct Session {
    session: Handle<KeyValidator>,
    host: String,
    port: u16,
}
Expand description

An open session with a host that can be used to send multiple signing requests.

Fields§

§session: Handle<KeyValidator>§host: String§port: u16

Implementations§

Source§

impl Session

Source

pub async fn send(&mut self, data: &Request) -> Result<Response, Error>

Send a signing request to the server and return a signing response.

§Examples
use signstar_request_signature::Request;
use signstar_request_signature::ssh::client::ConnectOptions;

let options = ConnectOptions::target("localhost".into(), 22);

let mut session = options.connect().await?;
let request = Request::for_file("package")?;
let response = session.send(&request).await?;
// process response
§Errors

Returns an error if sending or processing the signing request fails:

  • if the remote server rejects the signing request,
  • if the remote application exits unexpectedly,
  • the returned data cannot be deserialized into a Response,
  • if an SSH protocol error is encountered.
Source

pub async fn close(self) -> Result<(), Error>

Close the authentication session.

This function cleanly closes the session and informs the server that no further requests will be sent.

§Examples

This example shows that after the Session::close function is invoked no further requests can be sent.

use signstar_request_signature::ssh::client::ConnectOptions;

let options = ConnectOptions::target("localhost".into(), 22);

let mut session = options.connect().await?;
session.close();

// the session object has been consumed and cannot be reused
let request = Request::for_file("package")?;
let response = session.send(&request).await?;
§Errors

Returns an error if at any stage of the connecting process fails:

  • if the client public key is not set,
  • if the server public key is not pinned in the known hosts file,
  • if the client public key is not recognized by the server,
  • if the client authentication with the agent fails,
  • if an SSH protocol error is encountered.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V