pub struct RouteCost {
pub peer_id: String,
pub latency_ms: f64,
pub bandwidth_bps: u64,
pub reliability: f64,
}Expand description
Cost model for fetching content from a specific peer.
Fields§
§peer_id: StringPeer identifier
latency_ms: f64Round-trip latency in milliseconds
bandwidth_bps: u64Available bandwidth in bytes per second
reliability: f64Peer reliability score in range [0.0, 1.0]
Implementations§
Source§impl RouteCost
impl RouteCost
Sourcepub fn fetch_cost(&self, size_bytes: u64) -> f64
pub fn fetch_cost(&self, size_bytes: u64) -> f64
Estimated fetch cost in milliseconds for the given payload size.
Formula: (size_bytes / bandwidth_bps) * 1000 + latency_ms
Sourcepub fn weighted_score(&self) -> f64
pub fn weighted_score(&self) -> f64
Weighted quality score — higher is better.
Formula: reliability / fetch_cost(65536).max(1e-9)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RouteCost
impl RefUnwindSafe for RouteCost
impl Send for RouteCost
impl Sync for RouteCost
impl Unpin for RouteCost
impl UnsafeUnpin for RouteCost
impl UnwindSafe for RouteCost
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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