pub struct QualityPredictor { /* private fields */ }Expand description
Connection quality predictor
Implementations§
Source§impl QualityPredictor
impl QualityPredictor
Sourcepub fn new(
config: QualityPredictorConfig,
) -> Result<Self, QualityPredictorError>
pub fn new( config: QualityPredictorConfig, ) -> Result<Self, QualityPredictorError>
Create a new quality predictor
Sourcepub fn record_latency(&self, peer: PeerId, latency_ms: u64)
pub fn record_latency(&self, peer: PeerId, latency_ms: u64)
Record a latency measurement for a peer
Sourcepub fn record_bandwidth(&self, peer: PeerId, bytes_per_sec: u64)
pub fn record_bandwidth(&self, peer: PeerId, bytes_per_sec: u64)
Record a bandwidth measurement for a peer
Sourcepub fn record_success(&self, peer: PeerId)
pub fn record_success(&self, peer: PeerId)
Record a successful operation for a peer
Sourcepub fn record_failure(&self, peer: PeerId)
pub fn record_failure(&self, peer: PeerId)
Record a failed operation for a peer
Sourcepub fn predict_quality(&self, peer: &PeerId) -> Option<QualityPrediction>
pub fn predict_quality(&self, peer: &PeerId) -> Option<QualityPrediction>
Predict the quality for a specific peer
Sourcepub fn should_switch_connection(&self, peer: &PeerId) -> bool
pub fn should_switch_connection(&self, peer: &PeerId) -> bool
Check if a connection should be switched based on quality
Sourcepub fn get_best_peer(
&self,
peers: &[PeerId],
) -> Option<(PeerId, QualityPrediction)>
pub fn get_best_peer( &self, peers: &[PeerId], ) -> Option<(PeerId, QualityPrediction)>
Get the best peer among a list based on predicted quality
Sourcepub fn rank_peers(&self, peers: &[PeerId]) -> Vec<(PeerId, QualityPrediction)>
pub fn rank_peers(&self, peers: &[PeerId]) -> Vec<(PeerId, QualityPrediction)>
Get peers ranked by quality (best first)
Sourcepub fn remove_peer(&self, peer: &PeerId)
pub fn remove_peer(&self, peer: &PeerId)
Remove historical data for a peer
Sourcepub fn stats(&self) -> QualityPredictorStats
pub fn stats(&self) -> QualityPredictorStats
Get statistics
Auto Trait Implementations§
impl Freeze for QualityPredictor
impl !RefUnwindSafe for QualityPredictor
impl Send for QualityPredictor
impl Sync for QualityPredictor
impl Unpin for QualityPredictor
impl !UnwindSafe for QualityPredictor
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