Skip to main content

SDK

Struct SDK 

Source
pub struct SDK { /* private fields */ }

Implementations§

Source§

impl SDK

Source

pub fn app_key(&self) -> &PrivateKey

Returns the application key used by the SDK.

This should be kept secret and secure. Applications should store it safely.

Source

pub async fn upload<R: AsyncReadExt + Unpin + Send + 'static>( &self, reader: R, options: UploadOptions, ) -> Result<Object, UploadError>

Reads until EOF and uploads all slabs. The data will be erasure coded, encrypted, and uploaded using the uploader’s parameters.

§Arguments
  • r - The reader to read the data from. It will be read until EOF.
  • options - The UploadOptions to use for the upload.
§Returns

A new object containing the metadata needed to download the object. The object can be sealed and pinned to the indexer when ready.

Source

pub fn upload_packed(&self, options: UploadOptions) -> PackedUpload

Creates a new packed upload. This allows multiple objects to be packed together for more efficient uploads. The returned PackedUpload can be used to add objects to the upload, and then finalized to get the resulting objects.

§Arguments
§Returns

A PackedUpload that can be used to add objects and finalize the upload.

Source

pub async fn download<W: AsyncWriteExt + Unpin>( &self, w: &mut W, object: &Object, options: DownloadOptions, ) -> Result<(), DownloadError>

Downloads an object using the provided writer and options.

Source

pub async fn hosts(&self, query: HostQuery) -> Result<Vec<Host>, Error>

Retrieves a list of hosts from the indexer matching the provided query that can be used for uploading and downloading data.

§Arguments
  • query - Filtering criteria to select hosts.
Source

pub async fn account(&self) -> Result<Account, Error>

Retrieves account information from the indexer.

Source

pub async fn object(&self, key: &Hash256) -> Result<Object, Error>

Retrieves an object from the indexer by its key.

§Arguments
  • key - The key of the object to retrieve.
Source

pub async fn object_events( &self, cursor: Option<ObjectsCursor>, limit: Option<usize>, ) -> Result<Vec<ObjectEvent>, Error>

Retrieves a list of object events from the indexer. This can be used to synchronize local state with the indexer.

§Arguments
  • cursor - An optional cursor to continue from a previous call.
  • limit - An optional limit on the number of events to retrieve.
Source

pub async fn prune_slabs(&self) -> Result<(), Error>

Prunes unused slabs from the indexer. This helps to free up storage space by removing slabs that are no longer referenced by objects.

Source

pub async fn update_object_metadata(&self, object: &Object) -> Result<(), Error>

Updates the metadata of an object in the indexer. The object must already be pinned to the indexer.

§Arguments
  • object - The object to update.
Source

pub async fn delete_object(&self, id: &Hash256) -> Result<(), Error>

Deletes the object with the given id.

§Arguments
  • id - The id of the object to delete.
Source

pub fn share_object( &self, object: &Object, valid_until: DateTime<Utc>, ) -> Result<Url, Error>

Generates a shared URL for the given object that is valid until the specified time.

This object should be considered public even if the URL is kept secret, as anyone with the URL can access the object until the expiration time.

§Arguments
  • object - The object to share.
  • valid_until - The time until which the shared URL is valid.
Source

pub async fn shared_object<U: IntoUrl>( &self, share_url: U, ) -> Result<Object, Error>

Retrieves a shared object from the given share URL.

§Arguments
  • share_url - The URL of the shared object.
Source

pub async fn pin_object(&self, object: &Object) -> Result<(), Error>

Pins an object to the indexer

Source

pub async fn slab(&self, id: &Hash256) -> Result<PinnedSlab, Error>

Retrieves a pinned slab from the indexer by its id.

Trait Implementations§

Source§

impl Clone for SDK

Source§

fn clone(&self) -> SDK

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for SDK

§

impl !RefUnwindSafe for SDK

§

impl Send for SDK

§

impl Sync for SDK

§

impl Unpin for SDK

§

impl !UnwindSafe for SDK

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<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