pub struct PandaClient { /* private fields */ }Expand description
Client for the lores-p2panda-server gRPC API.
Implementations§
Source§impl PandaClient
impl PandaClient
Sourcepub async fn connect<D>(dst: D) -> Result<Self, Error>
pub async fn connect<D>(dst: D) -> Result<Self, Error>
Connect to a lores-p2panda-server at the given endpoint URI.
§Example
let client = lores_p2panda_client::PandaClient::connect("http://[::1]:50051").await.unwrap();Sourcepub fn connect_lazy<D>(dst: D) -> Result<Self, Error>
pub fn connect_lazy<D>(dst: D) -> Result<Self, Error>
Create a client with a lazy channel — no connection is made until the first RPC call, so the process starts cleanly even if the gRPC server is not yet available.
Sourcepub async fn publish(
&mut self,
region_id: [u8; 32],
app_namespace: impl Into<String>,
payload: impl Into<Vec<u8>>,
) -> Result<Response<PublishResponse>, Status>
pub async fn publish( &mut self, region_id: [u8; 32], app_namespace: impl Into<String>, payload: impl Into<Vec<u8>>, ) -> Result<Response<PublishResponse>, Status>
Publish an operation to a region+namespace topic.
Returns only after the operation has been persisted by the remote p2panda node, guaranteeing eventual propagation to peers.
Sourcepub async fn subscribe(
&mut self,
region_id: [u8; 32],
app_namespace: impl Into<String>,
) -> Result<Response<Streaming<OperationEvent>>, Status>
pub async fn subscribe( &mut self, region_id: [u8; 32], app_namespace: impl Into<String>, ) -> Result<Response<Streaming<OperationEvent>>, Status>
Subscribe to a region+namespace topic and receive a stream of
OperationEvents.
HTTP/2 flow control provides natural backpressure.
Sourcepub async fn list_regions(
&mut self,
) -> Result<Response<ListRegionsResponse>, Status>
pub async fn list_regions( &mut self, ) -> Result<Response<ListRegionsResponse>, Status>
List all regions the remote node knows about.
Auto Trait Implementations§
impl !Freeze for PandaClient
impl !RefUnwindSafe for PandaClient
impl Send for PandaClient
impl Sync for PandaClient
impl Unpin for PandaClient
impl UnsafeUnpin for PandaClient
impl !UnwindSafe for PandaClient
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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request