Bucket

Struct Bucket 

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

A bucket to store data in.

Implementations§

Source§

impl Bucket

Source

pub fn read_record(&self, entry: &str) -> ReadRecordBuilder

Create a record to write to the bucket.

§Arguments
  • entry - The entry to write to.
§Returns

Returns a record builder.

Source

pub fn query(&self, entry: &str) -> QueryBuilder

Create a record to write to the bucket.

§Arguments
  • entry - The entry to write to.
§Returns

Returns a record builder.

use reduct_rs::{ReductClient, ReductError};
use std::time::SystemTime;
use futures_util::StreamExt;

#[tokio::main]
async fn main() -> Result<(), ReductError> {
   let client = ReductClient::builder()
        .url("https://play.reduct.store")
        .api_token("reductstore")
        .build();
    let bucket = client.get_bucket("datasets").await?;
    let query = bucket.query("cats").limit(10).send().await?;
    tokio::pin!(query);
    while let Some(record) = query.next().await {
        let record = record?;
        let content_ = record.bytes().await?;
    }
    Ok(())
}
Source§

impl Bucket

Source

pub async fn remove_entry(&self, entry: &str) -> Result<(), ReductError>

Remove an entry from the bucket.

§Arguments
  • entry - The entry to remove.
§Returns

Returns an error if the entry could not be removed.

Source

pub fn remove_record(&self, entry: &str) -> RemoveRecordBuilder

Remove a record from an entry.

§Arguments
  • entry - The entry to remove.
§Returns

Returns an error if the record could not be removed.

Source

pub fn remove_batch(&self, entry: &str) -> WriteBatchBuilder

Remove records in a batch.

§Arguments
  • entry - The entry to remove.
§Returns

Returns a write batch builder.

§Example

use reduct_rs::{ReductClient, ReductError};

#[tokio::main]
async fn main() -> Result<(), ReductError> {
    let client = ReductClient::builder()
        .url("https://play.reduct.store")
        .api_token("reductstore")
        .build();
    let bucket = client.get_bucket("datasets").await?;
    let batch = bucket.remove_batch("cats");
    let errors = batch.add_timestamp_us(1000).add_timestamp_us(5000).send().await?;
    Ok(())
}
Source

pub fn remove_query(&self, entry: &str) -> RemoveQueryBuilder

Remove records in a query.

§Arguments
  • entry - The entry to remove.
§Returns

Returns a remove query builder.

§Example

use reduct_rs::{ReductClient, ReductError};

#[tokio::main]
async fn main() -> Result<(), ReductError> {
    let client = ReductClient::builder()
        .url("https://play.reduct.store")
        .api_token("reductstore")
        .build();

    let bucket = client.get_bucket("datasets").await?;
    let query = bucket.remove_query("cats");
    let removed_records = query.start_us(1000).stop_us(5000).send().await?;
    Ok(())
}
Source§

impl Bucket

Source

pub fn update_record(&self, entry: &str) -> UpdateRecordBuilder

Update labels of a record in an entry.

§Arguments
  • entry - The entry to update.
§Returns

Returns a builder to update the record and send the request.

Source

pub fn update_batch(&self, entry: &str) -> WriteBatchBuilder

Create a batch to update records in the bucket.

You should use RecordBuilder to create the records to update. Add labels to the record to update. Labels with an empty value will be removed.

§Arguments
  • entry - The entry to update.
§Returns

Returns a batch builder.

§Example
use tokio;
use reduct_rs::{ReductClient, ReductError};
use reduct_rs::RecordBuilder;
#[tokio::main]
async fn main() -> Result<(), ReductError> {
    let client = ReductClient::builder()
       .url("https://play.reduct.store")
       .api_token("reductstore")
       .build();
    let bucket = client.get_bucket("datasets").await?;
    let batch = bucket.update_batch("cats");
    let record1 = RecordBuilder::new()
        .timestamp_us(1000)
        .add_label("test".to_string(), "2".to_string())
        .add_label("x".to_string(), "".to_string()) // Remove label x
        .build();

    batch.add_record(record1).send().await?;
    Ok(())
}
Source§

impl Bucket

Source

pub fn write_record(&self, entry: &str) -> WriteRecordBuilder

Create a record to write to the bucket.

§Arguments
  • entry - The entry to write to.
§Returns

Returns a record builder.

§Example
use reduct_rs::{ReductClient, ReductError};
use std::time::SystemTime;

#[tokio::main]
async fn main() -> Result<(), ReductError> {
   let client = ReductClient::builder()
        .url("https://play.reduct.store")
        .api_token("reductstore")
        .build();
    let bucket = client.get_bucket("demo").await?;
    let record = bucket.write_record("entry-1").timestamp_us(1000).data("Some data").send().await?;
    Ok(())
}
Source

pub fn write_batch(&self, entry: &str) -> WriteBatchBuilder

Create a batch to write to the bucket.

§Arguments
  • entry - The entry to write to.
§Returns

Returns a batch builder.

Source§

impl Bucket

Source

pub fn name(&self) -> &str

Name of the bucket.

Source

pub fn server_url(&self) -> &str

URL of the server.

Source

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

Remove the bucket.

§Returns

Returns an error if the bucket could not be removed.

Source

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

Get the settings of the bucket.

§Returns

Return settings of the bucket

Source

pub async fn set_settings( &self, settings: BucketSettings, ) -> Result<(), ReductError>

Set the settings of the bucket.

§Arguments
  • settings - The new settings of the bucket.
§Returns

Returns an error if the bucket could not be found.

Source

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

Get full information about the bucket (stats, settings, entries).

Source

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

Get bucket stats.

Source

pub async fn entries(&self) -> Result<Vec<EntryInfo>, ReductError>

Get bucket entries.

Source

pub async fn rename_entry( &self, entry: &str, new_name: &str, ) -> Result<(), ReductError>

Rename an entry in the bucket.

§Arguments
  • entry - The entry to rename.
  • new_name - The new name of the entry.
§Returns

Returns an error if the entry could not be renamed.

Source

pub async fn rename(&mut self, new_name: &str) -> Result<(), ReductError>

Rename the bucket.

§Arguments
  • new_name - The new name of the bucket.
§Returns

Returns an error if the bucket could not be renamed.

Auto Trait Implementations§

§

impl Freeze for Bucket

§

impl !RefUnwindSafe for Bucket

§

impl Send for Bucket

§

impl Sync for Bucket

§

impl Unpin for Bucket

§

impl !UnwindSafe for Bucket

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,