Skip to main content

RelayNetwork

Struct RelayNetwork 

Source
pub struct RelayNetwork { /* private fields */ }

Implementations§

Source§

impl RelayNetwork

Source

pub fn new() -> Self

Source

pub fn with_config( hop_cost: f32, nutrient_per_hop: f32, trust_boost: f32, trust_degrade: f32, trust_halflife_secs: u64, ) -> Self

Source

pub fn add_agent(&mut self, id: AgentId, energy: f32)

Source

pub fn remove_agent(&mut self, id: AgentId)

Source

pub fn agent(&self, id: AgentId) -> Option<&Agent>

Source

pub fn agent_count(&self) -> usize

Source

pub fn alive_agents(&self) -> Vec<AgentId>

Source

pub fn set_trust(&mut self, from: AgentId, to: AgentId, level: f32)

Source

pub fn trust(&self, from: AgentId, to: AgentId) -> f32

Source

pub fn boost_trust(&mut self, from: AgentId, to: AgentId)

Source

pub fn degrade_trust(&mut self, from: AgentId, to: AgentId)

Source

pub fn decay_all_trust(&mut self, elapsed_secs: u64)

Apply time-based trust decay (halflife model)

Source

pub fn find_path( &self, from: AgentId, to: AgentId, max_hops: u32, ) -> Option<Vec<AgentId>>

Find best path using BFS with trust-weighted edges. Returns path as list of agent IDs (including source and destination).

Source

pub fn send(&mut self, msg: Message) -> DeliveryResult

Send a message through the relay network.

Source

pub fn spore_probe(&self, source: AgentId, max_hops: u32) -> Vec<AgentId>

Broadcast a probe to discover new routes. Returns all reachable agents from source.

Source

pub fn connection_count(&self) -> usize

Count active trust connections (edges with trust > 0)

Source

pub fn average_trust(&self) -> f32

Average trust across all connections

Source

pub fn strongest_connection(&self) -> Option<(AgentId, AgentId, f32)>

Strongest trust connection

Source

pub fn weakest_connection(&self) -> Option<(AgentId, AgentId, f32)>

Weakest non-zero trust connection

Trait Implementations§

Source§

impl Default for RelayNetwork

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.