pub struct DapiClient {
pub ca_certificate: Option<Certificate>,
/* private fields */
}Expand description
Access point to DAPI.
Fields§
§ca_certificate: Option<Certificate>Certificate Authority certificate to use for verifying the server’s certificate.
Implementations§
Source§impl DapiClient
impl DapiClient
Sourcepub fn new(address_list: AddressList, settings: RequestSettings) -> Self
pub fn new(address_list: AddressList, settings: RequestSettings) -> Self
Initialize new DapiClient and optionally override default settings.
Sourcepub fn with_ca_certificate(self, ca_cert: Certificate) -> Self
pub fn with_ca_certificate(self, ca_cert: Certificate) -> Self
Set CA certificate to use when verifying the server’s certificate.
§Arguments
pem_ca_cert- CA certificate in PEM format.
§Returns
DapiClient with CA certificate set.
Sourcepub fn address_list(&self) -> &AddressList
pub fn address_list(&self) -> &AddressList
Return the DapiClient address list.
Sourcepub fn get_live_addresses(&self) -> Vec<Address>
pub fn get_live_addresses(&self) -> Vec<Address>
Get all non-banned addresses from the address list.
Returns a vector of addresses that are not currently banned or whose ban period has expired. This is useful for diagnostics, monitoring, or when you need to know which DAPI nodes are currently available for making requests.
§Examples
use rs_dapi_client::{DapiClient, AddressList, RequestSettings};
let address_list = "http://127.0.0.1:3000,http://127.0.0.1:3001".parse().unwrap();
let client = DapiClient::new(address_list, RequestSettings::default());
// Get all currently available (non-banned) addresses
let live_addresses = client.get_live_addresses();
println!("Available DAPI nodes: {}", live_addresses.len());Source§impl DapiClient
impl DapiClient
Sourcepub const DUMP_FILE_PREFIX: &'static str = "msg"
pub const DUMP_FILE_PREFIX: &'static str = "msg"
Prefix of dump files.
Sourcepub fn dump_dir(self, dump_dir: Option<PathBuf>) -> Self
pub fn dump_dir(self, dump_dir: Option<PathBuf>) -> Self
Define directory where dumps of all traffic will be saved.
Each request and response pair will be saved to a JSON file in dump_dir.
Data is saved as DumpData structure.
Any errors are logged on warn level and ignored.
Dump file name is generated by DumpData::filename().
Useful for debugging and mocking. See also MockDapiClient::load().
Trait Implementations§
Source§impl Clone for DapiClient
impl Clone for DapiClient
Source§fn clone(&self) -> DapiClient
fn clone(&self) -> DapiClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DapiRequestExecutor for DapiClient
impl DapiRequestExecutor for DapiClient
Source§fn execute<'life0, 'async_trait, R>(
&'life0 self,
request: R,
settings: RequestSettings,
) -> Pin<Box<dyn Future<Output = ExecutionResult<R::Response, DapiClientError>> + Send + 'async_trait>>where
R: TransportRequest + Mockable + 'async_trait,
R::Response: Mockable,
TransportError: Mockable,
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait, R>(
&'life0 self,
request: R,
settings: RequestSettings,
) -> Pin<Box<dyn Future<Output = ExecutionResult<R::Response, DapiClientError>> + Send + 'async_trait>>where
R: TransportRequest + Mockable + 'async_trait,
R::Response: Mockable,
TransportError: Mockable,
Self: 'async_trait,
'life0: 'async_trait,
Execute the DapiRequest.
Auto Trait Implementations§
impl Freeze for DapiClient
impl RefUnwindSafe for DapiClient
impl Send for DapiClient
impl Sync for DapiClient
impl Unpin for DapiClient
impl UnwindSafe for DapiClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
impl<T, U> IntoPlatformVersioned<U> for Twhere
U: FromPlatformVersioned<T>,
Source§fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
fn into_platform_versioned(self, platform_version: &PlatformVersion) -> U
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].