pub struct VoltClient { /* private fields */ }Expand description
The main Volt client
Implementations§
Source§impl VoltClient
impl VoltClient
Sourcepub fn config(&self) -> Option<&VoltClientConfig>
pub fn config(&self) -> Option<&VoltClientConfig>
Get the client configuration
Sourcepub fn credential(&self) -> Option<&VoltCredential>
pub fn credential(&self) -> Option<&VoltCredential>
Get the credential manager
Sourcepub fn credential_mut(&mut self) -> Option<&mut VoltCredential>
pub fn credential_mut(&mut self) -> Option<&mut VoltCredential>
Get mutable credential manager
Sourcepub fn volt_config(&self) -> Option<&VoltConfig>
pub fn volt_config(&self) -> Option<&VoltConfig>
Get the Volt configuration
Sourcepub fn is_relayed(&self) -> bool
pub fn is_relayed(&self) -> bool
Check if connected via relay
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if connected
Sourcepub async fn initialise(
&mut self,
config: ConfigSource,
options: InitialiseOptions,
) -> Result<VoltClientConfig>
pub async fn initialise( &mut self, config: ConfigSource, options: InitialiseOptions, ) -> Result<VoltClientConfig>
Initialize the client with configuration
§Arguments
config- Either a path to a config file or a configuration objectoptions- Initialization options
Sourcepub async fn initialise_and_connect(
&mut self,
config: ConfigSource,
options: InitialiseOptions,
hello_payload: Option<Value>,
) -> Result<EventReceiver>
pub async fn initialise_and_connect( &mut self, config: ConfigSource, options: InitialiseOptions, hello_payload: Option<Value>, ) -> Result<EventReceiver>
Initialize and connect in one call
Sourcepub async fn connect(
&mut self,
hello_payload: Option<Value>,
) -> Result<EventReceiver>
pub async fn connect( &mut self, hello_payload: Option<Value>, ) -> Result<EventReceiver>
Connect to the Volt server
Sourcepub async fn disconnect(&mut self)
pub async fn disconnect(&mut self)
Disconnect from the Volt server
Sourcepub async fn request_access_blocking(
&self,
target_resource_id: &str,
access_type: VoltAccessType,
) -> Result<bool>
pub async fn request_access_blocking( &self, target_resource_id: &str, access_type: VoltAccessType, ) -> Result<bool>
Request resource access (blocking until decision)
Sourcepub async fn can_access_resource(&self, request: Value) -> Result<ApiResponse>
pub async fn can_access_resource(&self, request: Value) -> Result<ApiResponse>
Check if a resource can be accessed
Sourcepub async fn delete_resource(&self, request: Value) -> Result<ApiResponse>
pub async fn delete_resource(&self, request: Value) -> Result<ApiResponse>
Delete a resource
Sourcepub async fn discover_services(&self, request: Value) -> Result<ApiResponse>
pub async fn discover_services(&self, request: Value) -> Result<ApiResponse>
Discover services
Sourcepub async fn get_resource(&self, request: Value) -> Result<ApiResponse>
pub async fn get_resource(&self, request: Value) -> Result<ApiResponse>
Get a resource
Sourcepub async fn get_resources(&self, request: Value) -> Result<ApiResponse>
pub async fn get_resources(&self, request: Value) -> Result<ApiResponse>
Get multiple resources
Sourcepub async fn get_resource_ancestors(
&self,
request: Value,
) -> Result<ApiResponse>
pub async fn get_resource_ancestors( &self, request: Value, ) -> Result<ApiResponse>
Get resource ancestors
Sourcepub async fn get_resource_descendants(
&self,
request: Value,
) -> Result<ApiResponse>
pub async fn get_resource_descendants( &self, request: Value, ) -> Result<ApiResponse>
Get resource descendants
Sourcepub async fn request_access(
&self,
request: AccessRequest,
) -> Result<AccessResponse>
pub async fn request_access( &self, request: AccessRequest, ) -> Result<AccessResponse>
Request access to a resource
Sourcepub async fn save_resource(&self, request: Value) -> Result<ApiResponse>
pub async fn save_resource(&self, request: Value) -> Result<ApiResponse>
Save a resource
Sourcepub async fn authenticate(&self, request: Value) -> Result<ApiResponse>
pub async fn authenticate(&self, request: Value) -> Result<ApiResponse>
Authenticate
Sourcepub async fn bind(&self, request: Value) -> Result<ApiResponse>
pub async fn bind(&self, request: Value) -> Result<ApiResponse>
Bind to the Volt
Sourcepub async fn get_bindings(&self, request: Value) -> Result<ApiResponse>
pub async fn get_bindings(&self, request: Value) -> Result<ApiResponse>
Get bindings
Sourcepub async fn get_identities(&self, request: Value) -> Result<ApiResponse>
pub async fn get_identities(&self, request: Value) -> Result<ApiResponse>
Get identities
Sourcepub async fn get_identity(&self, request: Value) -> Result<ApiResponse>
pub async fn get_identity(&self, request: Value) -> Result<ApiResponse>
Get a specific identity
Sourcepub async fn get_policy(&self, request: Value) -> Result<ApiResponse>
pub async fn get_policy(&self, request: Value) -> Result<ApiResponse>
Get policy
Sourcepub async fn get_access(&self, request: Value) -> Result<ApiResponse>
pub async fn get_access(&self, request: Value) -> Result<ApiResponse>
Get access permissions for a resource
Sourcepub async fn get_settings(&self, request: Value) -> Result<ApiResponse>
pub async fn get_settings(&self, request: Value) -> Result<ApiResponse>
Get settings
Sourcepub async fn save_access(&self, request: Value) -> Result<ApiResponse>
pub async fn save_access(&self, request: Value) -> Result<ApiResponse>
Save access
Sourcepub async fn save_identity(&self, request: Value) -> Result<ApiResponse>
pub async fn save_identity(&self, request: Value) -> Result<ApiResponse>
Save identity
Sourcepub async fn save_settings(&self, request: Value) -> Result<ApiResponse>
pub async fn save_settings(&self, request: Value) -> Result<ApiResponse>
Save settings
Sourcepub async fn shutdown(&self, request: Value) -> Result<ApiResponse>
pub async fn shutdown(&self, request: Value) -> Result<ApiResponse>
Shutdown the Volt
Sourcepub async fn get_file_descendants(&self, request: Value) -> Result<ApiResponse>
pub async fn get_file_descendants(&self, request: Value) -> Result<ApiResponse>
Get file descendants
Sourcepub async fn get_file_content(&self, request: Value) -> Result<ApiResponse>
pub async fn get_file_content(&self, request: Value) -> Result<ApiResponse>
Get file content
Sourcepub async fn set_file_content(&self, request: Value) -> Result<ApiResponse>
pub async fn set_file_content(&self, request: Value) -> Result<ApiResponse>
Set file content
Sourcepub async fn create_database(&self, request: Value) -> Result<ApiResponse>
pub async fn create_database(&self, request: Value) -> Result<ApiResponse>
Create a database
Sourcepub async fn bulk_update(&self, request: Value) -> Result<ApiResponse>
pub async fn bulk_update(&self, request: Value) -> Result<ApiResponse>
Bulk update
Sourcepub async fn is_relay_connected(&self) -> bool
pub async fn is_relay_connected(&self) -> bool
Check if relay connection is established
Sourcepub async fn sync_document(
&self,
initial_request: SyncDocumentRequest,
) -> Result<(Sender<SyncDocumentRequest>, SyncDocumentStream)>
pub async fn sync_document( &self, initial_request: SyncDocumentRequest, ) -> Result<(Sender<SyncDocumentRequest>, SyncDocumentStream)>
Create a bidirectional streaming connection for document synchronization
This method creates a bidirectional stream for syncing CRDT documents using Y.js/yrs. The stream allows sending updates to the server and receiving updates from other clients.
§Returns
A tuple of:
mpsc::Sender<volt::SyncDocumentRequest>- Use this to send requests to the serverStreaming<volt::SyncDocumentResponse>- Use this to receive responses from the server
§Example
let (tx, mut rx) = client.sync_document().await?;
// Send initial sync request
tx.send(volt::SyncDocumentRequest {
sync_start: Some(volt::SyncDocumentStart {
database_id: "my-db".to_string(),
document_id: "my-doc".to_string(),
state_vector: vec![],
read_only: false,
read_only_fallback: false,
}),
..Default::default()
}).await?;
// Receive responses
while let Some(response) = rx.next().await {
match response {
Ok(resp) => println!("Received: {:?}", resp),
Err(e) => eprintln!("Error: {:?}", e),
}
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for VoltClient
impl !RefUnwindSafe for VoltClient
impl Send for VoltClient
impl Sync for VoltClient
impl Unpin for VoltClient
impl !UnwindSafe for VoltClient
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> 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