pub struct Session { /* private fields */ }Expand description
A session for grouping related block requests
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
id: SessionId,
config: SessionConfig,
event_tx: Option<UnboundedSender<SessionEvent>>,
) -> Self
pub fn new( id: SessionId, config: SessionConfig, event_tx: Option<UnboundedSender<SessionEvent>>, ) -> Self
Create a new session
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
Get current state
Sourcepub fn add_block(
&self,
cid: Cid,
priority: Option<Priority>,
) -> Result<(), SessionError>
pub fn add_block( &self, cid: Cid, priority: Option<Priority>, ) -> Result<(), SessionError>
Add a block to the session
Sourcepub fn add_blocks(
&self,
cids: &[Cid],
priority: Option<Priority>,
) -> Result<(), SessionError>
pub fn add_blocks( &self, cids: &[Cid], priority: Option<Priority>, ) -> Result<(), SessionError>
Add multiple blocks to the session
Sourcepub fn mark_received(&self, cid: &Cid, data: &Bytes) -> Result<(), SessionError>
pub fn mark_received(&self, cid: &Cid, data: &Bytes) -> Result<(), SessionError>
Mark a block as received
Sourcepub fn mark_failed(&self, cid: &Cid, error: String) -> Result<(), SessionError>
pub fn mark_failed(&self, cid: &Cid, error: String) -> Result<(), SessionError>
Mark a block as failed
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
Get session statistics
Sourcepub fn pending_blocks(&self) -> Vec<Cid> ⓘ
pub fn pending_blocks(&self) -> Vec<Cid> ⓘ
Get pending blocks (not yet received)
Sourcepub async fn wait_completion(&self) -> Result<SessionStats, SessionError>
pub async fn wait_completion(&self) -> Result<SessionStats, SessionError>
Wait for session completion
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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