Expand description
Rollkit Rust Client Library
This library provides a Rust client for interacting with Rollkit nodes via gRPC.
§Example
use ev_client::{Client, HealthClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to a Rollkit node
let client = Client::connect("http://localhost:50051").await?;
// Check health
let health = HealthClient::new(&client);
let is_healthy = health.is_healthy().await?;
println!("Node healthy: {}", is_healthy);
Ok(())
}§Using the Builder Pattern
use ev_client::Client;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with custom timeouts
let client = Client::builder()
.endpoint("http://localhost:50051")
.timeout(Duration::from_secs(30))
.connect_timeout(Duration::from_secs(10))
.build()
.await?;
Ok(())
}§Using TLS
use ev_client::Client;
use tonic::transport::ClientTlsConfig;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with TLS enabled
let client = Client::builder()
.endpoint("https://secure-node.rollkit.dev")
.tls() // Enable TLS with default configuration
.build()
.await?;
// Or with custom TLS configuration
let tls_config = ClientTlsConfig::new()
.domain_name("secure-node.rollkit.dev");
let client = Client::builder()
.endpoint("https://secure-node.rollkit.dev")
.tls_config(tls_config)
.build()
.await?;
Ok(())
}Re-exports§
pub use client::Client;pub use client::ClientBuilder;pub use error::ClientError;pub use error::Result;pub use health::HealthClient;pub use p2p::P2PClient;pub use signer::SignerClient;pub use store::StoreClient;
Modules§
Structs§
- Client
TlsConfig - Configures TLS settings for endpoints.