iroh_blobs::api::remote

Struct Remote

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

API to compute request and to download from remote nodes.

Usually you want to first find out what, if any, data you have locally. This can be done using Remote::local, which inspects the local store and returns a LocalInfo.

From this you can compute various values such as the number of locally present bytes. You can also compute a request to get the missing data using LocalInfo::missing.

Once you have a request, you can execute it using Remote::execute_get. Executing a request will store to the local store, but otherwise does not take the available data into account.

If you are not interested in the details and just want your data, you can use Remote::fetch. This will internally do the dance described above.

Implementations§

Source§

impl Remote

Source

pub async fn local_for_request( &self, request: impl Into<Arc<GetRequest>>, ) -> Result<LocalInfo>

Source

pub async fn local( &self, content: impl Into<HashAndFormat>, ) -> Result<LocalInfo>

Get the local info for a given blob or hash sequence, at the present time.

Source

pub fn fetch( &self, conn: impl GetConnection + Send + 'static, content: impl Into<HashAndFormat>, ) -> GetProgress

Source

pub async fn fetch_sink( &self, conn: impl GetConnection, content: impl Into<HashAndFormat>, progress: impl Sink<u64, Error = Error>, ) -> GetResult<Stats>

Get a blob or hash sequence from the given connection, taking the locally available ranges into account.

You can provide a progress channel to get updates on the download progress. This progress is the aggregated number of downloaded payload bytes in the request.

This will return the stats of the download.

Source

pub fn observe( &self, conn: Connection, request: ObserveRequest, ) -> impl Stream<Item = Result<Bitfield>> + 'static

Source

pub fn execute_push( &self, conn: Connection, request: PushRequest, ) -> PushProgress

Source

pub async fn execute_push_sink( &self, conn: Connection, request: PushRequest, progress: impl Sink<u64, Error = Error>, ) -> Result<Stats>

Push the given blob or hash sequence to a remote node.

Note that many nodes will reject push requests. Also, this is an experimental feature for now.

Source

pub fn execute_get(&self, conn: Connection, request: GetRequest) -> GetProgress

Source

pub fn execute_get_with_opts( &self, conn: Connection, request: GetRequest, ) -> GetProgress

Source

pub async fn execute_get_sink( &self, conn: Connection, request: GetRequest, progress: impl Sink<u64, Error = Error>, ) -> GetResult<Stats>

Execute a get request without taking the locally available ranges into account.

You can provide a progress channel to get updates on the download progress. This progress is the aggregated number of downloaded payload bytes in the request.

This will download the data again even if the data is locally present.

This will return the stats of the download.

Source

pub fn execute_get_many( &self, conn: Connection, request: GetManyRequest, ) -> GetProgress

Source

pub async fn execute_get_many_sink( &self, conn: Connection, request: GetManyRequest, progress: impl Sink<u64, Error = Error>, ) -> GetResult<Stats>

Execute a get request without taking the locally available ranges into account.

You can provide a progress channel to get updates on the download progress. This progress is the aggregated number of downloaded payload bytes in the request.

This will download the data again even if the data is locally present.

This will return the stats of the download.

Trait Implementations§

Source§

impl Clone for Remote

Source§

fn clone(&self) -> Remote

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 Debug for Remote

Source§

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

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

impl RefCast for Remote

Source§

type From = Client<Command, Request, StoreService>

Source§

fn ref_cast(_from: &Self::From) -> &Self

Source§

fn ref_cast_mut(_from: &mut Self::From) -> &mut Self

Auto Trait Implementations§

§

impl Freeze for Remote

§

impl !RefUnwindSafe for Remote

§

impl Send for Remote

§

impl Sync for Remote

§

impl Unpin for Remote

§

impl !UnwindSafe for Remote

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. 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, 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

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
§

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

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
§

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