Skip to main content

LocalNodeClient

Struct LocalNodeClient 

Source
pub struct LocalNodeClient { /* private fields */ }

Implementations§

Source§

impl LocalNodeClient

Source

pub async fn connect( endpoint: impl AsRef<Path>, expected_node_id: &NodeId, role: ClientRole, access_token: &str, ) -> Result<Self, NodeClientError>

Source

pub async fn connect_loopback( endpoint: SocketAddr, expected_node_id: &NodeId, role: ClientRole, access_token: &str, ) -> Result<Self, NodeClientError>

Source

pub async fn adopt( stream: impl NodeClientStream + 'static, expected_node_id: &NodeId, role: ClientRole, access_token: &str, ) -> Result<Self, NodeClientError>

Runs the client handshake over a stream the caller already opened – or, on a call-home relay, one it ACCEPTED.

Identical to what Self::connect and Self::connect_loopback do after their own connect call: same hello, same mutual challenge-response over both nonces, same compatibility negotiation. The direction the socket was opened in is not an input to any of it, and this constructor is the proof of that – it is the same code path, entered one step later.

expected_node_id still has to be known up front, because the server proof is computed from that node’s own access token. On a call-home connection the relay learns it from the node’s NodeCallHomeAnnounce preface, which selects a token and nothing else – see that type’s own doc comment.

Source

pub fn hello(&self) -> &NodeHello

Source

pub async fn send( &mut self, request: NodeRequest, ) -> Result<u64, NodeClientError>

Source

pub async fn recv(&mut self) -> Result<ServerFrame, NodeClientError>

Source

pub async fn request( &mut self, request: NodeRequest, ) -> Result<NodeResponse, NodeClientError>

Source

pub fn take_event(&mut self) -> Option<NodeEventEnvelope>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.