Trait duniter_wotb::WebOfTrust
[−]
[src]
pub trait WebOfTrust { fn get_max_link(&self) -> usize; fn set_max_link(&mut self, max_link: usize); fn add_node(&mut self) -> NodeId; fn rem_node(&mut self) -> Option<NodeId>; fn size(&self) -> usize; fn is_enabled(&self, id: NodeId) -> Option<bool>; fn set_enabled(&mut self, id: NodeId, enabled: bool) -> Option<bool>; fn get_enabled(&self) -> Vec<NodeId>; fn get_disabled(&self) -> Vec<NodeId>; fn add_link(&mut self, source: NodeId, target: NodeId) -> NewLinkResult; fn rem_link(&mut self, source: NodeId, target: NodeId) -> RemLinkResult; fn has_link(&self, source: NodeId, target: NodeId) -> HasLinkResult; fn get_links_source(&self, target: NodeId) -> Option<Vec<NodeId>>; fn issued_count(&self, id: NodeId) -> Option<usize>; fn get_sentries(&self, sentry_requirement: usize) -> Vec<NodeId>; fn get_non_sentries(&self, sentry_requirement: usize) -> Vec<NodeId>; fn get_paths(
&self,
from: NodeId,
to: NodeId,
k_max: u32
) -> Vec<Vec<NodeId>>; fn compute_distance(
&self,
params: WotDistanceParameters
) -> Option<WotDistance>; fn is_outdistanced(&self, params: WotDistanceParameters) -> Option<bool>; fn from_file(&mut self, path: &str) -> Result<Vec<u8>, WotParseError> { ... } fn to_file(
&self,
path: &str,
blockstamp: &[u8]
) -> Result<(), WotWriteError> { ... } }
Trait for a Web Of Trust.
Allow to provide other implementations of the WoT
logic instead of the legacy C++
translated one.
Required Methods
fn get_max_link(&self) -> usize
Get the maximum number of links per user.
fn set_max_link(&mut self, max_link: usize)
Set the maximum number of links per user.
fn add_node(&mut self) -> NodeId
Add a new node.
fn rem_node(&mut self) -> Option<NodeId>
Remove the last node.
Returns None
if the WoT was empty, otherwise new top node id.
fn size(&self) -> usize
Get the size of the WoT.
fn is_enabled(&self, id: NodeId) -> Option<bool>
Check if given node is enabled.
Returns None
if this node doesn't exist.
fn set_enabled(&mut self, id: NodeId, enabled: bool) -> Option<bool>
Set the enabled state of given node.
Returns Null
if this node doesn't exist, enabled
otherwise.
fn get_enabled(&self) -> Vec<NodeId>
Get enabled node array.
fn get_disabled(&self) -> Vec<NodeId>
Get disabled node array.
fn add_link(&mut self, source: NodeId, target: NodeId) -> NewLinkResult
Try to add a link from the source to the target.
fn rem_link(&mut self, source: NodeId, target: NodeId) -> RemLinkResult
Try to remove a link from the source to the target.
fn has_link(&self, source: NodeId, target: NodeId) -> HasLinkResult
Test if there is a link from the source to the target.
fn get_links_source(&self, target: NodeId) -> Option<Vec<NodeId>>
Get the list of links source for this target.
Returns None
if this node doesn't exist.
fn issued_count(&self, id: NodeId) -> Option<usize>
Get the number of issued links by a node.
Returns None
if this node doesn't exist.
fn get_sentries(&self, sentry_requirement: usize) -> Vec<NodeId>
Get sentries array.
fn get_non_sentries(&self, sentry_requirement: usize) -> Vec<NodeId>
Get non sentries array.
fn get_paths(&self, from: NodeId, to: NodeId, k_max: u32) -> Vec<Vec<NodeId>>
Get paths from one node to the other.
fn compute_distance(&self, params: WotDistanceParameters) -> Option<WotDistance>
Compute distance between a node and the network.
Returns None
if this node doesn't exist.
fn is_outdistanced(&self, params: WotDistanceParameters) -> Option<bool>
Test if a node is outdistanced in the network.
Returns Node
if this node doesn't exist.
Provided Methods
fn from_file(&mut self, path: &str) -> Result<Vec<u8>, WotParseError>
Load WebOfTrust from binary file
fn to_file(&self, path: &str, blockstamp: &[u8]) -> Result<(), WotWriteError>
Write WebOfTrust to binary file
Implementors
impl WebOfTrust for LegacyWebOfTrust
impl WebOfTrust for RustyWebOfTrust