pub struct Session {
pub id: NodeId,
pub addr: Address,
pub link: Link,
pub persistent: bool,
pub state: State,
pub subscribe: Option<Subscribe>,
pub last_active: LocalTime,
pub queue: VecDeque<QueuedFetch>,
/* private fields */
}Expand description
A peer session. Each connected peer will have one session.
Fields§
§id: NodeIdPeer id.
addr: AddressPeer address.
link: LinkConnection direction.
persistent: boolWhether we should attempt to re-connect to this peer upon disconnection.
state: StatePeer connection state.
subscribe: Option<Subscribe>Peer subscription.
last_active: LocalTimeLast time a message was received from the peer.
queue: VecDeque<QueuedFetch>Fetch queue.
Implementations§
Source§impl Session
impl Session
pub fn outbound( id: NodeId, addr: Address, persistent: bool, rng: Rng, limits: Limits, ) -> Self
pub fn inbound( id: NodeId, addr: Address, persistent: bool, rng: Rng, time: LocalTime, limits: Limits, ) -> Self
pub fn is_connecting(&self) -> bool
pub fn is_stable(&self) -> bool
pub fn is_connected(&self) -> bool
pub fn is_disconnected(&self) -> bool
pub fn is_initial(&self) -> bool
pub fn is_at_capacity(&self) -> bool
pub fn is_fetching(&self, rid: &RepoId) -> bool
Sourcepub fn queue_fetch(&mut self, fetch: QueuedFetch) -> Result<(), QueueError>
pub fn queue_fetch(&mut self, fetch: QueuedFetch) -> Result<(), QueueError>
Queue a fetch. Returns true if it was added to the queue, and false if
it already was present in the queue.
pub fn dequeue_fetch(&mut self) -> Option<QueuedFetch>
pub fn attempts(&self) -> usize
Sourcepub fn fetching(&mut self, rid: RepoId)
pub fn fetching(&mut self, rid: RepoId)
Mark this session as fetching the given RID.
§Panics
If it is already fetching that RID, or the session is disconnected.
pub fn fetched(&mut self, rid: RepoId)
pub fn to_attempted(&mut self)
pub fn to_connected(&mut self, since: LocalTime)
Sourcepub fn to_disconnected(&mut self, since: LocalTime, retry_at: LocalTime)
pub fn to_disconnected(&mut self, since: LocalTime, retry_at: LocalTime)
Move the session state to “disconnected”. Returns any pending RID that was requested.
Sourcepub fn to_initial(&mut self)
pub fn to_initial(&mut self)
Return to initial state from disconnected state. This state transition happens when we attempt to re-connect to a disconnected peer.
pub fn ping( &mut self, since: LocalTime, reactor: &mut Outbox, ) -> Result<(), Error>
Trait Implementations§
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<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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