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
impl Remote
pub async fn local_for_request( &self, request: impl Into<Arc<GetRequest>>, ) -> Result<LocalInfo>
Sourcepub async fn local(
&self,
content: impl Into<HashAndFormat>,
) -> Result<LocalInfo>
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.
pub fn fetch( &self, conn: impl GetConnection + Send + 'static, content: impl Into<HashAndFormat>, ) -> GetProgress
Sourcepub async fn fetch_sink(
&self,
conn: impl GetConnection,
content: impl Into<HashAndFormat>,
progress: impl Sink<u64, Error = Error>,
) -> GetResult<Stats>
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.
pub fn observe( &self, conn: Connection, request: ObserveRequest, ) -> impl Stream<Item = Result<Bitfield>> + 'static
pub fn execute_push( &self, conn: Connection, request: PushRequest, ) -> PushProgress
Sourcepub async fn execute_push_sink(
&self,
conn: Connection,
request: PushRequest,
progress: impl Sink<u64, Error = Error>,
) -> Result<Stats>
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.
pub fn execute_get(&self, conn: Connection, request: GetRequest) -> GetProgress
pub fn execute_get_with_opts( &self, conn: Connection, request: GetRequest, ) -> GetProgress
Sourcepub async fn execute_get_sink(
&self,
conn: Connection,
request: GetRequest,
progress: impl Sink<u64, Error = Error>,
) -> GetResult<Stats>
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.
pub fn execute_get_many( &self, conn: Connection, request: GetManyRequest, ) -> GetProgress
Sourcepub async fn execute_get_many_sink(
&self,
conn: Connection,
request: GetManyRequest,
progress: impl Sink<u64, Error = Error>,
) -> GetResult<Stats>
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.