Skip to main content

VoltClient

Struct VoltClient 

Source
pub struct VoltClient { /* private fields */ }
Expand description

The main Volt client

Implementations§

Source§

impl VoltClient

Source

pub fn new() -> Result<Self>

Create a new Volt client

Source

pub fn config(&self) -> Option<&VoltClientConfig>

Get the client configuration

Source

pub fn credential(&self) -> Option<&VoltCredential>

Get the credential manager

Source

pub fn credential_mut(&mut self) -> Option<&mut VoltCredential>

Get mutable credential manager

Source

pub fn volt_config(&self) -> Option<&VoltConfig>

Get the Volt configuration

Source

pub fn is_relayed(&self) -> bool

Check if connected via relay

Source

pub async fn is_connected(&self) -> bool

Check if connected

Source

pub async fn close(&mut self)

Close the client and release resources

Source

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 object
  • options - Initialization options
Source

pub async fn initialise_and_connect( &mut self, config: ConfigSource, options: InitialiseOptions, hello_payload: Option<Value>, ) -> Result<EventReceiver>

Initialize and connect in one call

Source

pub async fn connect( &mut self, hello_payload: Option<Value>, ) -> Result<EventReceiver>

Connect to the Volt server

Source

pub async fn disconnect(&mut self)

Disconnect from the Volt server

Source

pub async fn request_access_blocking( &self, target_resource_id: &str, access_type: VoltAccessType, ) -> Result<bool>

Request resource access (blocking until decision)

Source

pub async fn can_access_resource(&self, request: Value) -> Result<ApiResponse>

Check if a resource can be accessed

Source

pub async fn delete_resource(&self, request: Value) -> Result<ApiResponse>

Delete a resource

Source

pub async fn discover_services(&self, request: Value) -> Result<ApiResponse>

Discover services

Source

pub async fn get_resource(&self, request: Value) -> Result<ApiResponse>

Get a resource

Source

pub async fn get_resources(&self, request: Value) -> Result<ApiResponse>

Get multiple resources

Source

pub async fn get_resource_ancestors( &self, request: Value, ) -> Result<ApiResponse>

Get resource ancestors

Source

pub async fn get_resource_descendants( &self, request: Value, ) -> Result<ApiResponse>

Get resource descendants

Source

pub async fn request_access( &self, request: AccessRequest, ) -> Result<AccessResponse>

Request access to a resource

Source

pub async fn save_resource(&self, request: Value) -> Result<ApiResponse>

Save a resource

Source

pub async fn authenticate(&self, request: Value) -> Result<ApiResponse>

Authenticate

Source

pub async fn bind(&self, request: Value) -> Result<ApiResponse>

Bind to the Volt

Source

pub async fn get_bindings(&self, request: Value) -> Result<ApiResponse>

Get bindings

Source

pub async fn get_identities(&self, request: Value) -> Result<ApiResponse>

Get identities

Source

pub async fn get_identity(&self, request: Value) -> Result<ApiResponse>

Get a specific identity

Source

pub async fn get_policy(&self, request: Value) -> Result<ApiResponse>

Get policy

Source

pub async fn get_access(&self, request: Value) -> Result<ApiResponse>

Get access permissions for a resource

Source

pub async fn get_settings(&self, request: Value) -> Result<ApiResponse>

Get settings

Source

pub async fn save_access(&self, request: Value) -> Result<ApiResponse>

Save access

Source

pub async fn save_identity(&self, request: Value) -> Result<ApiResponse>

Save identity

Source

pub async fn save_settings(&self, request: Value) -> Result<ApiResponse>

Save settings

Source

pub async fn shutdown(&self, request: Value) -> Result<ApiResponse>

Shutdown the Volt

Source

pub async fn get_file_descendants(&self, request: Value) -> Result<ApiResponse>

Get file descendants

Source

pub async fn get_file_content(&self, request: Value) -> Result<ApiResponse>

Get file content

Source

pub async fn set_file_content(&self, request: Value) -> Result<ApiResponse>

Set file content

Source

pub async fn create_database(&self, request: Value) -> Result<ApiResponse>

Create a database

Source

pub async fn bulk_update(&self, request: Value) -> Result<ApiResponse>

Bulk update

Source

pub async fn is_relay_connected(&self) -> bool

Check if relay connection is established

Source

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 server
  • Streaming<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§

Source§

impl Default for VoltClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<M> Meta for M
where M: Default,