Struct ReductClient

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

ReductStore client.

Implementations§

Source§

impl ReductClient

Source

pub fn builder() -> ReductClientBuilder

Create a new ReductClientBuilder.

§Examples
use reduct_rs::ReductClient;

let client = ReductClient::builder()
   .set_url("https://reductstore.com")
   .set_api_token("my-api-token")
   .build();
Source

pub fn url(&self) -> &str

Get the URL of the ReductStore instance.

Source

pub fn api_token(&self) -> &str

Get the API token.

Source

pub async fn server_info(&self) -> Result<ServerInfo, ReductError>

Get the server info.

§Returns

The server info

Source

pub async fn bucket_list(&self) -> Result<BucketInfoList, ReductError>

Get the bucket list.

§Returns

The bucket list.

Source

pub fn create_bucket(&self, name: &str) -> BucketBuilder

Create a bucket.

§Arguments
  • name - The name of the bucket
§Returns

a bucket builder to set the bucket settings

Source

pub async fn get_bucket(&self, name: &str) -> Result<Bucket, ReductError>

Get a bucket.

§Arguments
  • name - The name of the bucket
§Returns

the bucket or an error

Source

pub async fn alive(&self) -> Result<(), ReductError>

Check if the server is alive.

§Returns

Ok if the server is alive, otherwise an error.

Source

pub async fn me(&self) -> Result<Token, ReductError>

Get the token with permissions for the current user.

§Returns

The token or HttpError

Source

pub async fn create_token( &self, name: &str, permissions: Permissions, ) -> Result<String, ReductError>

Create an access token

§Arguments
  • name - The name of the token
  • permissions - The permissions of the token
§Returns

The token value or HttpError

Source

pub async fn get_token(&self, name: &str) -> Result<Token, ReductError>

Get an access token

§Arguments
  • name - The name of the token
§Returns

The token or an error

Source

pub async fn delete_token(&self, name: &str) -> Result<(), ReductError>

Delete an access token

§Arguments
  • name - The name of the token
§Returns

Ok if the token was deleted, otherwise an error

Source

pub async fn list_tokens(&self) -> Result<Vec<Token>, ReductError>

List all access tokens

§Returns

The list of tokens or an error

Source

pub async fn list_replications( &self, ) -> Result<Vec<ReplicationInfo>, ReductError>

Get list of replications

§Returns

The list of replications or an error

Source

pub async fn get_replication( &self, name: &str, ) -> Result<FullReplicationInfo, ReductError>

Get full replication info

§Arguments
  • name - The name of the replication
§Returns

The replication info or an error

Source

pub fn create_replication(&self, name: &str) -> ReplicationBuilder

Create a replication

§Arguments
  • name - The name of the replication
§Returns

a replication builder to set the replication settings

§Example
use reduct_rs::ReductClient;

#[tokio::main]
async fn main() {
    let client = ReductClient::builder()
        .url("http://127.0.0.1:8383")
        .api_token("my-api-token")
        .build();

    client.create_replication("test-replication")
        .src_bucket("test-bucket-1")
        .dst_bucket("test-bucket-2")
        .dst_host("https://play.reduct.store")
        .dst_token("reductstore")
        .send()
        .await
        .unwrap();
}
Source

pub async fn update_replication( &self, name: &str, settings: ReplicationSettings, ) -> Result<(), ReductError>

Update a replication

§Arguments
  • name - The name of the replication
  • settings - The replication settings
§Returns

Ok if the replication was updated, otherwise an error

Source

pub async fn delete_replication(&self, name: &str) -> Result<(), ReductError>

Delete a replication

§Arguments
  • name - The name of the replication
§Returns

Ok if the replication was deleted, otherwise an error

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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<T> ErasedDestructor for T
where T: 'static,