pub struct PeerClient { /* private fields */ }Expand description
The pulling side of a verified channel: it reads the serving peer’s listing, then makes
requests one at a time. Its requests take &self, so it can back a
BlobSource (super::ChannelBlobSource).
Once any exchange fails part-way, the stream’s framing can no longer be trusted: the client is broken and refuses every later request rather than reading a stray frame as an answer.
Implementations§
Source§impl PeerClient
impl PeerClient
Sourcepub async fn open(channel: PeerChannel) -> Result<Self, PeeringError>
pub async fn open(channel: PeerChannel) -> Result<Self, PeeringError>
Read the serving peer’s listing, first saying this device offers nothing where the
pair’s protocol carries an opening offer. A listing with more than MAX_LISTING
artifacts, an address that is not a content address, or an artifact longer than
MAX_ARTIFACT_LEN is refused whole.
§Errors
PeeringError::Codec for a malformed listing, PeeringError::PeerRefused when the
peer refused the session, or the channel’s I/O or timeout failure.
Sourcepub async fn open_offering(
channel: PeerChannel,
offer: &Offer,
) -> Result<Self, PeeringError>
pub async fn open_offering( channel: PeerChannel, offer: &Offer, ) -> Result<Self, PeeringError>
As open, first sending offer — what this device holds and its cursor —
so the serving side lists an artifact cut to what this device is missing. On a channel
negotiated below OFFER_EXCHANGE_PROTOCOL nothing is sent, and the peer lists what it
would have without an offer. Once an opening is sent — this offer, or nothing where the
offer exceeds MAX_OFFER_PAGES — the listing is awaited for the I/O timeout plus
LISTING_BUILD_ALLOWANCE, while the peer cuts and seals its artifact; so is the
listing open awaits on a channel that carries an opening.
§Errors
As open, and the channel’s failure while sending the offer.
Sourcepub fn peer(&self) -> &VerifiedPeer
pub fn peer(&self) -> &VerifiedPeer
The peer the handshake verified.
Sourcepub fn is_broken(&self) -> bool
pub fn is_broken(&self) -> bool
Whether an exchange failed part-way, so the client refuses every later request.
Sourcepub async fn range(
&self,
address: &str,
start: u64,
max_len: Option<u64>,
) -> Result<Vec<u8>, RangeFailure>
pub async fn range( &self, address: &str, start: u64, max_len: Option<u64>, ) -> Result<Vec<u8>, RangeFailure>
Pull bytes of address from start: at most max_len, and never more than
MAX_RANGE. The bytes are the peer’s until the whole artifact hashes to its address.
The answer must arrive whole within the channel’s I/O timeout plus its length at
MIN_PULL_RATE.
§Errors
A RangeFailure carrying whatever arrived before the failure; its error is
PeeringError::Timeout when a frame, or the whole answer, came too slowly.
Sourcepub async fn acknowledge(&self, ack: &HandOffAck) -> Result<(), PeeringError>
pub async fn acknowledge(&self, ack: &HandOffAck) -> Result<(), PeeringError>
Deliver an acknowledgement and wait for the peer to take it.
§Errors
PeeringError::PeerRefused when the peer refused it, or the channel’s failure.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PeerClient
impl !RefUnwindSafe for PeerClient
impl !UnwindSafe for PeerClient
impl Send for PeerClient
impl Sync for PeerClient
impl Unpin for PeerClient
impl UnsafeUnpin for PeerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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