AsyncSecretConnection

Struct AsyncSecretConnection 

Source
pub struct AsyncSecretConnection<Io> { /* private fields */ }
Available on crate feature async only.
Expand description

Encrypted connection between peers in a CometBFT network, implemented using asynchronous I/O provided by the Tokio async runtime.

Implementations§

Source§

impl<Io: AsyncReadExt + AsyncWriteExt + Send + Sync + Unpin> AsyncSecretConnection<Io>

Source

pub async fn new<Identity>(io: Io, identity_key: &Identity) -> Result<Self>
where Identity: Signer<Signature>, VerifyingKey: for<'a> From<&'a Identity>,

Performs a handshake and returns a new AsyncSecretConnection, authenticating ourselves with the provided Identity (Ed25519 signing key).

The IdentitySecret type can be used as an identity_key.

§Errors
  • if sharing of the pubkey fails
  • if sharing of the signature fails
  • if receiving the signature fails
  • if verifying the signature fails
Source§

impl<Io> AsyncSecretConnection<Io>

Source

pub fn local_public_key(&self) -> &PublicKey

Get the local (i.e. our) PublicKey.

Source

pub fn peer_public_key(&self) -> &PublicKey

Returns the remote peer’s PublicKey.

Source

pub fn split(self) -> (AsyncSecretReader<Io>, AsyncSecretWriter<Io>)

Split this AsyncSecretConnection into an AsyncSecretReader and AsyncSecretWriter which can be used independently of each other.

Trait Implementations§

Source§

impl<Io: AsyncReadExt + Send + Sync + Unpin> AsyncReadMsg for AsyncSecretConnection<Io>

Source§

fn read_msg<M: Message + Default>( &mut self, ) -> impl Future<Output = Result<M>> + Send + Sync

Read from the underlying I/O object, decrypting the data and decoding it into the given Protobuf message.
Source§

impl<Io: AsyncWriteExt + Send + Sync + Unpin> AsyncWriteMsg for AsyncSecretConnection<Io>

Source§

fn write_msg<M: Message>( &mut self, msg: M, ) -> impl Future<Output = Result<()>> + Send + Sync

Encode the given Protobuf as bytes, encrypted it, and write the ciphertext to the underlying I/O object. Read more

Auto Trait Implementations§

§

impl<Io> Freeze for AsyncSecretConnection<Io>

§

impl<Io> RefUnwindSafe for AsyncSecretConnection<Io>

§

impl<Io> Send for AsyncSecretConnection<Io>
where Io: Send,

§

impl<Io> Sync for AsyncSecretConnection<Io>
where Io: Sync,

§

impl<Io> Unpin for AsyncSecretConnection<Io>

§

impl<Io> UnwindSafe for AsyncSecretConnection<Io>

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.