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
impl Session
Sourcepub async fn send(&mut self, data: &Request) -> Result<Response, Error>
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.
Sourcepub async fn close(self) -> Result<(), Error>
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§
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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