Skip to main content

MarpleDB

Struct MarpleDB 

Source
#[non_exhaustive]
pub struct MarpleDB { /* private fields */ }
Expand description

Client for the MarpleDB API.

Implementations§

Source§

impl MarpleDB

Source

pub fn new(url: &str, token: &str) -> Result<Self>

Creates a new client for url using a bearer API token.

The URL should point at the MarpleDB API root and usually ends in /api/v1, for example https://db.marpledata.com/api/v1.

Source

pub fn builder() -> MarpleDBBuilder

Creates a builder for configuring a client.

Use the builder when you need custom timeouts, a user agent, or preconfigured reqwest::Client instances.

Source

pub fn storage_client(&self) -> &Client

Returns the header-free storage client used for pre-signed download and upload URLs.

Direct storage URLs are already authenticated by the URL itself. This client intentionally does not include MarpleDB authorization headers.

Source

pub async fn get<Q, R>(&self, endpoint: &str, query: &Q) -> Result<R>

Sends a GET request and deserializes the JSON response.

Use &() for endpoints without query parameters. The response type is inferred from assignment or turbofish annotations.

Source

pub async fn post<B, R>(&self, endpoint: &str, body: &B) -> Result<R>

Sends a POST request with a JSON body and deserializes the JSON response.

The body may be any serializable value. Use serde_json::Value as the response type when calling untyped endpoints.

Source

pub async fn delete<B, R>(&self, endpoint: &str, body: &B) -> Result<R>

Sends a DELETE request with a JSON body and deserializes the JSON response.

The body may be any serializable value. Pass &serde_json::json!({}) when the endpoint expects an empty JSON object.

Source

pub async fn health(&self) -> Result<HealthResponse>

Checks MarpleDB API health.

Source

pub async fn get_streams(&self) -> Result<Vec<Stream>>

Lists all streams visible to the token.

Source

pub async fn get_stream(&self, stream_name: &str) -> Result<Stream>

Finds a stream by name.

Source

pub async fn create_stream<S: Serialize + ?Sized>( &self, stream_name: &str, options: &S, ) -> Result<Stream>

Creates a stream with a name and serializable options object.

options must serialize to a JSON object. The SDK adds the name field before sending the request.

Source

pub async fn update_stream<S: Serialize + ?Sized>( &self, stream_id: i32, options: &S, ) -> Result<Stream>

Updates a stream with a serializable options object.

options must serialize to the JSON object expected by the MarpleDB stream update endpoint.

Source

pub async fn get_datasets(&self, stream_id: i32) -> Result<Vec<Dataset>>

Lists datasets in a stream.

Source

pub async fn get_datapool_datasets(&self, pool: &str) -> Result<Vec<Dataset>>

Lists all datasets in a datapool.

Source

pub async fn get_datapool_ingest_queue( &self, pool: &str, ) -> Result<Vec<Dataset>>

Lists datasets currently in the ingest queue for a datapool.

Source

pub async fn get_dataset( &self, stream_id: i32, dataset_id: i32, ) -> Result<Dataset>

Fetches a dataset by stream id and dataset id.

Returns a pre-signed URL for downloading a dataset’s original uploaded file.

The returned URL is already authenticated and may expire. Use MarpleDB::storage_client or another header-free HTTP client to fetch it.

Source

pub async fn wait_for_import( &self, stream_id: i32, dataset_id: i32, timeout: Duration, ) -> Result<Dataset>

Waits until an import reaches a terminal status or times out.

Polls every 500ms. Finished and Live return the dataset, while Failed and PostprocessingFailed return Error::ImportFailed.

Source§

impl MarpleDB

Source

pub async fn push_file( &self, stream_id: i32, file_path: impl AsRef<Path>, options: PushFileOptions, ) -> Result<Dataset>

Uploads a file to a stream and returns the created dataset.

Trait Implementations§

Source§

impl Clone for MarpleDB

Source§

fn clone(&self) -> MarpleDB

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MarpleDB

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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