Skip to main content

Handle

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 23 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_for( &mut self, id: RepoId, namespaces: impl IntoIterator<Item = PublicKey>, ) -> 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 block(&mut self, id: PublicKey) -> 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_for( &mut self, id: RepoId, namespaces: impl IntoIterator<Item = PublicKey>, ) -> 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>; // Provided methods fn seeds(&mut self, id: RepoId) -> Result<Seeds, Self::Error> { ... } fn announce_refs(&mut self, id: RepoId) -> Result<RefsAt, 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_for( &mut self, id: RepoId, namespaces: impl IntoIterator<Item = PublicKey>, ) -> Result<Seeds, Self::Error>

Look up the seeds of a given repository in the routing table and report sync status for namespaces.

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 block(&mut self, id: PublicKey) -> Result<bool, Self::Error>

Set the following policy to block for 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_for( &mut self, id: RepoId, namespaces: impl IntoIterator<Item = PublicKey>, ) -> Result<RefsAt, Self::Error>

Notify the service that a repository has been updated, and references for the given namespaces should be announced over the network.

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.

Provided Methods§

Source

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

👎Deprecated: use seeds_for instead

Look up the seeds of a given repository in the routing table.

Source

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

👎Deprecated: use announce_refs_for instead

Notify the service that a repository has been updated, and references should be announced over the network.

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§