Struct iroh_blobs::rpc::client::blobs::Client

source ·
pub struct Client<C = BoxedConnector<RpcService>> { /* private fields */ }
Available on crate feature rpc only.
Expand description

Iroh blobs client.

Implementations§

source§

impl<C> Client<C>
where C: Connector<RpcService>,

source

pub fn new(rpc: RpcClient<RpcService, C>) -> Self

Create a new client

source

pub fn tags(&self) -> Client<C>

Get a tags client.

source

pub async fn status(&self, hash: Hash) -> Result<BlobStatus>

Check if a blob is completely stored on the node.

Note that this will return false for blobs that are partially stored on the node.

source

pub async fn has(&self, hash: Hash) -> Result<bool>

Check if a blob is completely stored on the node.

This is just a convenience wrapper around status that returns a boolean.

source

pub async fn batch(&self) -> Result<Batch<C>>

Create a new batch for adding data.

A batch is a context in which temp tags are created and data is added to the node. Temp tags are automatically deleted when the batch is dropped, leading to the data being garbage collected unless a permanent tag is created for it.

source

pub async fn read(&self, hash: Hash) -> Result<Reader>

Stream the contents of a a single blob.

Returns a Reader, which can report the size of the blob before reading it.

source

pub async fn read_at( &self, hash: Hash, offset: u64, len: ReadAtLen ) -> Result<Reader>

Read offset + len from a single blob.

If len is None it will read the full blob.

source

pub async fn read_to_bytes(&self, hash: Hash) -> Result<Bytes>

Read all bytes of single blob.

This allocates a buffer for the full blob. Use only if you know that the blob you’re reading is small. If not sure, use Self::read and check the size with Reader::size before calling Reader::read_to_bytes.

source

pub async fn read_at_to_bytes( &self, hash: Hash, offset: u64, len: ReadAtLen ) -> Result<Bytes>

Read all bytes of single blob at offset for length len.

This allocates a buffer for the full length.

source

pub async fn add_from_path( &self, path: PathBuf, in_place: bool, tag: SetTagOption, wrap: WrapOption ) -> Result<AddProgress>

Import a blob from a filesystem path.

path should be an absolute path valid for the file system on which the node runs. If in_place is true, Iroh will assume that the data will not change and will share it in place without copying to the Iroh data directory.

source

pub async fn create_collection( &self, collection: Collection, tag: SetTagOption, tags_to_delete: Vec<Tag> ) -> Result<(Hash, Tag)>

Create a collection from already existing blobs.

For automatically clearing the tags for the passed in blobs you can set tags_to_delete to those tags, and they will be deleted once the collection is created.

source

pub async fn add_reader( &self, reader: impl AsyncRead + Unpin + Send + 'static, tag: SetTagOption ) -> Result<AddProgress>

Write a blob by passing an async reader.

source

pub async fn add_stream( &self, input: impl Stream<Item = Result<Bytes>> + Send + Unpin + 'static, tag: SetTagOption ) -> Result<AddProgress>

Write a blob by passing a stream of bytes.

source

pub async fn add_bytes(&self, bytes: impl Into<Bytes>) -> Result<AddOutcome>

Write a blob by passing bytes.

source

pub async fn add_bytes_named( &self, bytes: impl Into<Bytes>, name: impl Into<Tag> ) -> Result<AddOutcome>

Write a blob by passing bytes, setting an explicit tag name.

source

pub async fn validate( &self, repair: bool ) -> Result<impl Stream<Item = Result<ValidateProgress>>>

Validate hashes on the running node.

If repair is true, repair the store by removing invalid data.

source

pub async fn consistency_check( &self, repair: bool ) -> Result<impl Stream<Item = Result<ConsistencyCheckProgress>>>

Validate hashes on the running node.

If repair is true, repair the store by removing invalid data.

source

pub async fn download( &self, hash: Hash, node: NodeAddr ) -> Result<DownloadProgress>

Download a blob from another node and add it to the local database.

source

pub async fn download_hash_seq( &self, hash: Hash, node: NodeAddr ) -> Result<DownloadProgress>

Download a hash sequence from another node and add it to the local database.

source

pub async fn download_with_opts( &self, hash: Hash, opts: DownloadOptions ) -> Result<DownloadProgress>

Download a blob, with additional options.

source

pub async fn export( &self, hash: Hash, destination: PathBuf, format: ExportFormat, mode: ExportMode ) -> Result<ExportProgress>

Export a blob from the internal blob store to a path on the node’s filesystem.

destination should be an writeable, absolute path on the local node’s filesystem.

If format is set to ExportFormat::Collection, and the hash refers to a collection, all children of the collection will be exported. See ExportFormat for details.

The mode argument defines if the blob should be copied to the target location or moved out of the internal store into the target location. See ExportMode for details.

source

pub async fn list(&self) -> Result<impl Stream<Item = Result<BlobInfo>>>

List all complete blobs.

source

pub async fn list_incomplete( &self ) -> Result<impl Stream<Item = Result<IncompleteBlobInfo>>>

List all incomplete (partial) blobs.

source

pub async fn get_collection(&self, hash: Hash) -> Result<Collection>

Read the content of a collection.

source

pub fn list_collections( &self ) -> Result<impl Stream<Item = Result<CollectionInfo>>>

List all collections.

source

pub async fn delete_blob(&self, hash: Hash) -> Result<()>

Delete a blob.

Warning: this operation deletes the blob from the local store even if it is tagged. You should usually not do this manually, but rely on the node to remove data that is not tagged.

Trait Implementations§

source§

impl<C: Clone> Clone for Client<C>

source§

fn clone(&self) -> Client<C>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<C: Debug> Debug for Client<C>

source§

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

Formats the value using the given formatter. Read more
source§

impl<C> SimpleStore for Client<C>
where C: Connector<RpcService>,

source§

async fn load(&self, hash: Hash) -> Result<Bytes>

Load a blob from the store

Auto Trait Implementations§

§

impl<C> Freeze for Client<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for Client<C>
where C: RefUnwindSafe,

§

impl<C> Send for Client<C>
where C: Send,

§

impl<C> Sync for Client<C>
where C: Sync,

§

impl<C> Unpin for Client<C>
where C: Unpin,

§

impl<C> UnwindSafe for Client<C>
where C: UnwindSafe,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T