pub struct Client { /* private fields */ }Expand description
Client is the main handle for interacting with iroh-services. It communicates with
iroh-services entirely through an iroh endpoint, and is configured through a builder.
Client requires either an Ssh Key or ApiSecret
use iroh::{Endpoint, endpoint::presets};
use iroh_services::Client;
async fn build_client() -> anyhow::Result<()> {
let endpoint = Endpoint::bind(presets::N0).await?;
// needs IROH_SERVICES_API_SECRET set to an environment variable
// client will now push endpoint metrics to iroh-services.
let client = Client::builder(&endpoint)
.api_secret_from_str("MY_API_SECRET")?
.build()
.await;
Ok(())
}Implementations§
Source§impl Client
impl Client
pub fn builder(endpoint: &Endpoint) -> ClientBuilder
Sourcepub async fn name(&self) -> Result<Option<String>, Error>
pub async fn name(&self) -> Result<Option<String>, Error>
Read the current endpoint name from the local client.
Sourcepub async fn set_name(&self, name: impl Into<String>) -> Result<(), Error>
pub async fn set_name(&self, name: impl Into<String>) -> Result<(), Error>
Name the active endpoint cloud-side.
names can be any UTF-8 string, with a min length of 2 bytes, and maximum length of 128 bytes. name uniqueness is not enforced.
Sourcepub async fn push_metrics(&self) -> Result<(), Error>
pub async fn push_metrics(&self) -> Result<(), Error>
immediately send a single dump of metrics to iroh-services. It’s not necessary to call this function if you’re using a non-zero metrics interval, which will automatically propagate metrics on the set interval for you
Sourcepub async fn grant_capability(
&self,
remote_id: EndpointId,
caps: impl IntoIterator<Item = impl Into<Cap>>,
) -> Result<(), Error>
pub async fn grant_capability( &self, remote_id: EndpointId, caps: impl IntoIterator<Item = impl Into<Cap>>, ) -> Result<(), Error>
Grant capabilities to a remote endpoint. Creates a signed RCAN token and sends it to iroh-services for storage. The remote can then use this token when dialing back to authorize its requests.
Sourcepub async fn net_diagnostics(
&self,
send: bool,
) -> Result<DiagnosticsReport, Error>
pub async fn net_diagnostics( &self, send: bool, ) -> Result<DiagnosticsReport, Error>
run local network status diagnostics, optionally uploading the results
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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> 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