pub struct NymNodeApiClientRetriever { /* private fields */ }Expand description
Builder-style helper for obtaining a validated crate::api::Client for a nym-node.
On top of the basic port-probing performed by try_get_valid_nym_node_api_client,
this struct optionally:
- verifies that the node’s self-reported ed25519 identity matches an expected value (e.g. the identity committed on-chain during bonding), and
- checks the cryptographic signature on the node’s host information.
Both checks require an extra HTTP round-trip to the node’s /host-information endpoint
and are skipped when neither option is enabled.
Implementations§
Source§impl NymNodeApiClientRetriever
impl NymNodeApiClientRetriever
Sourcepub fn new(user_agent: impl Into<UserAgent>) -> Self
pub fn new(user_agent: impl Into<UserAgent>) -> Self
Creates a new retriever with the given user agent. All optional checks (identity verification, host information signature) are disabled by default — use the builder methods to enable them.
Sourcepub fn with_expected_identity(self, expected_identity: Option<String>) -> Self
pub fn with_expected_identity(self, expected_identity: Option<String>) -> Self
If set, the node’s self-reported ed25519 identity (from its /host-information
endpoint) will be compared against this value. A mismatch produces
crate::error::Error::MismatchedIdentity.
Sourcepub fn with_custom_port(self, port: Option<u16>) -> Self
pub fn with_custom_port(self, port: Option<u16>) -> Self
Prepend http://<host>:<port> to the list of addresses probed during
get_client, so it is tried before the standard ports.
Sourcepub fn with_verify_host_information(self) -> Self
pub fn with_verify_host_information(self) -> Self
Enable cryptographic verification of the node’s host information signature.
When enabled, get_client will return
crate::error::Error::MissignedHostInformation if the signature is invalid.
Sourcepub async fn get_client(
self,
base_host: &str,
node_id: u32,
) -> Result<ApiClientWithHostInformation, Error>
pub async fn get_client( self, base_host: &str, node_id: u32, ) -> Result<ApiClientWithHostInformation, Error>
Probe the node’s HTTP API, perform any configured verification, and return the
client together with the SignedHostInformation if it was fetched.
The host information is only retrieved when identity verification or signature
checking is enabled. When neither is active, the returned
ApiClientWithHostInformation::host_information will be None.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NymNodeApiClientRetriever
impl RefUnwindSafe for NymNodeApiClientRetriever
impl Send for NymNodeApiClientRetriever
impl Sync for NymNodeApiClientRetriever
impl Unpin for NymNodeApiClientRetriever
impl UnsafeUnpin for NymNodeApiClientRetriever
impl UnwindSafe for NymNodeApiClientRetriever
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more