Trait Handle

Source
pub trait Handle:
    Clone
    + Sync
    + Send {
    type Sessions;
    type Events: IntoIterator<Item = Self::Event>;
    type Event;
    type Error: Error + Send + Sync + 'static;

Show 20 methods // Required methods fn nid(&self) -> Result<PublicKey, Self::Error>; fn is_running(&self) -> bool; fn listen_addrs(&self) -> Result<Vec<SocketAddr>, Self::Error>; fn config(&self) -> Result<Config, Self::Error>; fn connect( &mut self, node: PublicKey, addr: Address, opts: ConnectOptions, ) -> Result<ConnectResult, Self::Error>; fn disconnect(&mut self, node: PublicKey) -> Result<(), Self::Error>; fn seeds(&mut self, id: RepoId) -> Result<Seeds, Self::Error>; fn fetch( &mut self, id: RepoId, from: PublicKey, timeout: Duration, ) -> Result<FetchResult, Self::Error>; fn seed(&mut self, id: RepoId, scope: Scope) -> Result<bool, Self::Error>; fn follow( &mut self, id: PublicKey, alias: Option<Alias>, ) -> Result<bool, Self::Error>; fn unseed(&mut self, id: RepoId) -> Result<bool, Self::Error>; fn unfollow(&mut self, id: PublicKey) -> Result<bool, Self::Error>; fn announce_refs(&mut self, id: RepoId) -> Result<RefsAt, Self::Error>; fn announce_inventory(&mut self) -> Result<(), Self::Error>; fn add_inventory(&mut self, rid: RepoId) -> Result<bool, Self::Error>; fn shutdown(self) -> Result<(), Self::Error>; fn sessions(&self) -> Result<Self::Sessions, Self::Error>; fn session(&self, node: PublicKey) -> Result<Option<Session>, Self::Error>; fn subscribe(&self, timeout: Duration) -> Result<Self::Events, Self::Error>; fn debug(&self) -> Result<Value, Self::Error>;
}
Expand description

A handle to send commands to the node or request information.

Required Associated Types§

Source

type Sessions

The peer sessions type.

Source

type Events: IntoIterator<Item = Self::Event>

Source

type Event

Source

type Error: Error + Send + Sync + 'static

The error returned by all methods.

Required Methods§

Source

fn nid(&self) -> Result<PublicKey, Self::Error>

Get the local Node ID.

Source

fn is_running(&self) -> bool

Check if the node is running.

Source

fn listen_addrs(&self) -> Result<Vec<SocketAddr>, Self::Error>

Get the node’s bound listen addresses.

Source

fn config(&self) -> Result<Config, Self::Error>

Get the current node configuration.

Source

fn connect( &mut self, node: PublicKey, addr: Address, opts: ConnectOptions, ) -> Result<ConnectResult, Self::Error>

Connect to a peer.

Source

fn disconnect(&mut self, node: PublicKey) -> Result<(), Self::Error>

Disconnect from a peer.

Source

fn seeds(&mut self, id: RepoId) -> Result<Seeds, Self::Error>

Lookup the seeds of a given repository in the routing table.

Source

fn fetch( &mut self, id: RepoId, from: PublicKey, timeout: Duration, ) -> Result<FetchResult, Self::Error>

Fetch a repository from the network.

Source

fn seed(&mut self, id: RepoId, scope: Scope) -> Result<bool, Self::Error>

Start seeding the given repo. May update the scope. Does nothing if the repo is already seeded.

Source

fn follow( &mut self, id: PublicKey, alias: Option<Alias>, ) -> Result<bool, Self::Error>

Start following the given peer.

Source

fn unseed(&mut self, id: RepoId) -> Result<bool, Self::Error>

Un-seed the given repo and delete it from storage.

Source

fn unfollow(&mut self, id: PublicKey) -> Result<bool, Self::Error>

Unfollow the given peer.

Source

fn announce_refs(&mut self, id: RepoId) -> Result<RefsAt, Self::Error>

Notify the service that a project has been updated, and announce local refs.

Source

fn announce_inventory(&mut self) -> Result<(), Self::Error>

Announce local inventory.

Source

fn add_inventory(&mut self, rid: RepoId) -> Result<bool, Self::Error>

Notify the service that our inventory was updated with the given repository.

Source

fn shutdown(self) -> Result<(), Self::Error>

Ask the service to shutdown.

Source

fn sessions(&self) -> Result<Self::Sessions, Self::Error>

Query the peer session state.

Source

fn session(&self, node: PublicKey) -> Result<Option<Session>, Self::Error>

Query the state of a peer session. Returns None if no session was found.

Source

fn subscribe(&self, timeout: Duration) -> Result<Self::Events, Self::Error>

Subscribe to node events.

Source

fn debug(&self) -> Result<Value, Self::Error>

Return debug information as a JSON value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§