pub struct CoLinkClient<T> { /* private fields */ }Implementations§
Source§impl CoLinkClient<Channel>
impl CoLinkClient<Channel>
Source§impl<T> CoLinkClient<T>where
T: GrpcService<BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
impl<T> CoLinkClient<T>where
T: GrpcService<BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
pub fn new(inner: T) -> Self
pub fn with_origin(inner: T, origin: Uri) -> Self
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> CoLinkClient<InterceptedService<T, F>>where
F: Interceptor,
T::ResponseBody: Default,
T: Service<Request<BoxBody>, Response = Response<<T as GrpcService<BoxBody>>::ResponseBody>>,
<T as Service<Request<BoxBody>>>::Error: Into<StdError> + Send + Sync,
Sourcepub fn send_compressed(self, encoding: CompressionEncoding) -> Self
pub fn send_compressed(self, encoding: CompressionEncoding) -> Self
Compress requests with the given encoding.
This requires the server to support it otherwise it might respond with an error.
Sourcepub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self
Enable decompressing responses.
Sourcepub fn max_decoding_message_size(self, limit: usize) -> Self
pub fn max_decoding_message_size(self, limit: usize) -> Self
Limits the maximum size of a decoded message.
Default: 4MB
Sourcepub fn max_encoding_message_size(self, limit: usize) -> Self
pub fn max_encoding_message_size(self, limit: usize) -> Self
Limits the maximum size of an encoded message.
Default: usize::MAX
Sourcepub async fn generate_token(
&mut self,
request: impl IntoRequest<GenerateTokenRequest>,
) -> Result<Response<Jwt>, Status>
pub async fn generate_token( &mut self, request: impl IntoRequest<GenerateTokenRequest>, ) -> Result<Response<Jwt>, Status>
Given a valid JWT or valid signature and an expiration timestamp, generates a new JWT with the expiration time set to the input timestamp. Requires user jwt or user consent with signature. You cannot refresh a host JWT.
Sourcepub async fn import_user(
&mut self,
request: impl IntoRequest<UserConsent>,
) -> Result<Response<Jwt>, Status>
pub async fn import_user( &mut self, request: impl IntoRequest<UserConsent>, ) -> Result<Response<Jwt>, Status>
Generates a JWT from a user with a public/secret key pair. The generated JWT specifies the user’s privilege as a user, contains their user_id, which is a base64 encoding of the provided public key. Requires host JWT.
Sourcepub async fn create_entry(
&mut self,
request: impl IntoRequest<StorageEntry>,
) -> Result<Response<StorageEntry>, Status>
pub async fn create_entry( &mut self, request: impl IntoRequest<StorageEntry>, ) -> Result<Response<StorageEntry>, Status>
Creates an entry in CoLink storage.
In the entry passed in to the call, the key_name field must be nonempty. Every other field is is ignored.
Requires user or host JWT.
Returns a key_path with current timestamp included.
Sourcepub async fn read_entries(
&mut self,
request: impl IntoRequest<StorageEntries>,
) -> Result<Response<StorageEntries>, Status>
pub async fn read_entries( &mut self, request: impl IntoRequest<StorageEntries>, ) -> Result<Response<StorageEntries>, Status>
Retrieves entries from CoLink storage.
One and only one field among key_name and key_path is nonempty. If both are nonempty, an error is returned.
If key_name is nonempty, returns the latest version of the entry with that key name.
This is done by first obtaining the timestamp representing the latest version of the entry,
and then retrieving the entry with that timestamp by including the timestamp in key_path.
If key_path is nonempty, returns the entry with the corresponding key path.
If you’re looking for a specific version of an entry, use specify the timestamp inside the key_path field.
In both cases, the key_name field is empty in the returned StorageEntry. key_path and payload are nonempty.
If an entry is not found. An error is returned.
Note that the returned order of the entries is NOT guaranteed to be the same as the order of the input.
Requires user or host JWT.
Sourcepub async fn update_entry(
&mut self,
request: impl IntoRequest<StorageEntry>,
) -> Result<Response<StorageEntry>, Status>
pub async fn update_entry( &mut self, request: impl IntoRequest<StorageEntry>, ) -> Result<Response<StorageEntry>, Status>
Updates an entry in CoLink storage.
In the entry passed in to the call, the key_name field must be nonempty. Every other field is is ignored.
Creates a new entry with the current timestamp in the key_path field.
Sets the latest entry to current timestamp.
Requires user or host JWT.
Returns a key_path with current timestamp included.
Sourcepub async fn delete_entry(
&mut self,
request: impl IntoRequest<StorageEntry>,
) -> Result<Response<StorageEntry>, Status>
pub async fn delete_entry( &mut self, request: impl IntoRequest<StorageEntry>, ) -> Result<Response<StorageEntry>, Status>
Deletes an entry from CoLink storage. Sets the latest entry to current timestamp, but unlike UpdateEntry, we do not create a new entry with the current timestamp in the key_path field. Therefore the current timestamp points to nothing. Requires user or host JWT. Returns a key_path with current timestamp included.
Sourcepub async fn read_keys(
&mut self,
request: impl IntoRequest<ReadKeysRequest>,
) -> Result<Response<StorageEntries>, Status>
pub async fn read_keys( &mut self, request: impl IntoRequest<ReadKeysRequest>, ) -> Result<Response<StorageEntries>, Status>
Returns list of entries in CoLink storage whose key_path starts with input prefix. Requires user or host JWT.
Sourcepub async fn create_task(
&mut self,
request: impl IntoRequest<Task>,
) -> Result<Response<Task>, Status>
pub async fn create_task( &mut self, request: impl IntoRequest<Task>, ) -> Result<Response<Task>, Status>
An initiator creates a task. Generate a task_id for this task. Represent user(initiator) to sign a decision for this task. Sync this task with other participants. Update task status in storage. In request, protocol_name, protocol_param, participants are required. parent_task is optional. In response, only task_id is included. Require user JWT.
Sourcepub async fn confirm_task(
&mut self,
request: impl IntoRequest<ConfirmTaskRequest>,
) -> Result<Response<Empty>, Status>
pub async fn confirm_task( &mut self, request: impl IntoRequest<ConfirmTaskRequest>, ) -> Result<Response<Empty>, Status>
A participant confirms a task. Represent user to sign a decision for this task. Sync the decision to the initiator. Update task status in storage. The task is ignored if is_approved and is_rejected are both false in the decision. In request, task_id is required. Require user JWT.
Sourcepub async fn finish_task(
&mut self,
request: impl IntoRequest<Task>,
) -> Result<Response<Empty>, Status>
pub async fn finish_task( &mut self, request: impl IntoRequest<Task>, ) -> Result<Response<Empty>, Status>
A participant finishes a task. Update task status in storage. In request, task_id is required. Require user JWT.
Sourcepub async fn request_info(
&mut self,
request: impl IntoRequest<Empty>,
) -> Result<Response<RequestInfoResponse>, Status>
pub async fn request_info( &mut self, request: impl IntoRequest<Empty>, ) -> Result<Response<RequestInfoResponse>, Status>
Request the information of the core, including the URI of MQ, and the public key of the core. Return MQ Information optionally and core public key for this user. Also return the IP address of the requestor. JWT is optional: when the request includes jwt, the uri of mq is returned.
Sourcepub async fn subscribe(
&mut self,
request: impl IntoRequest<SubscribeRequest>,
) -> Result<Response<MqQueueName>, Status>
pub async fn subscribe( &mut self, request: impl IntoRequest<SubscribeRequest>, ) -> Result<Response<MqQueueName>, Status>
Subscribe to changes in the storage. It lets you subscribe to all changes of key_name in storage since start_timestamp. The subscription message is formatted in SubscriptionMessage. Require user JWT.
Sourcepub async fn unsubscribe(
&mut self,
request: impl IntoRequest<MqQueueName>,
) -> Result<Response<Empty>, Status>
pub async fn unsubscribe( &mut self, request: impl IntoRequest<MqQueueName>, ) -> Result<Response<Empty>, Status>
Unsubscribe the changes in the storage. Require user JWT.
Sourcepub async fn start_protocol_operator(
&mut self,
request: impl IntoRequest<StartProtocolOperatorRequest>,
) -> Result<Response<ProtocolOperatorInstanceId>, Status>
pub async fn start_protocol_operator( &mut self, request: impl IntoRequest<StartProtocolOperatorRequest>, ) -> Result<Response<ProtocolOperatorInstanceId>, Status>
Start a protocol operator. It returns a unique instance_id for the newly started operator. In request, protocol_name and user_id are required. In response, instance_id is included. Require user or host JWT.
Sourcepub async fn stop_protocol_operator(
&mut self,
request: impl IntoRequest<ProtocolOperatorInstanceId>,
) -> Result<Response<Empty>, Status>
pub async fn stop_protocol_operator( &mut self, request: impl IntoRequest<ProtocolOperatorInstanceId>, ) -> Result<Response<Empty>, Status>
Stop a protocol operator. In request, instance_id is required. Require user or host JWT.
Sourcepub async fn inter_core_sync_task(
&mut self,
request: impl IntoRequest<Task>,
) -> Result<Response<Empty>, Status>
pub async fn inter_core_sync_task( &mut self, request: impl IntoRequest<Task>, ) -> Result<Response<Empty>, Status>
InterCore RPC. Sync a task. If it receives a task with unknown task_id, then create this task in storage and send task status to MQ. Otherwise, update decisions in storage. If all participants’ decisions are received and it is the initiator, sync the decisions to other participants. If all participants’ decisions are received, send task status to MQ. The task status in the request should be ignored even if it exists. Require guest or user JWT.
Sourcepub async fn inter_core_sync_task_with_reverse_connection(
&mut self,
request: impl IntoRequest<Task>,
) -> Result<Response<Streaming<Task>>, Status>
pub async fn inter_core_sync_task_with_reverse_connection( &mut self, request: impl IntoRequest<Task>, ) -> Result<Response<Streaming<Task>>, Status>
InterCore RPC. Same as InterCoreSyncTask and create a reverse connection. When A uses this RPC to sync a task with B, it creates a reverse connection from B to A. When B uses that reverse connection to sync tasks with A, B would not need to use a JWT, and A automatically assumes that B has guest privilege. Require guest or user JWT.
Trait Implementations§
Source§impl<T: Clone> Clone for CoLinkClient<T>
impl<T: Clone> Clone for CoLinkClient<T>
Source§fn clone(&self) -> CoLinkClient<T>
fn clone(&self) -> CoLinkClient<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> !Freeze for CoLinkClient<T>
impl<T> RefUnwindSafe for CoLinkClient<T>where
T: RefUnwindSafe,
impl<T> Send for CoLinkClient<T>where
T: Send,
impl<T> Sync for CoLinkClient<T>where
T: Sync,
impl<T> Unpin for CoLinkClient<T>where
T: Unpin,
impl<T> UnwindSafe for CoLinkClient<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
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>
T in a tonic::Request