Struct radicle::node::Node

source ·
pub struct Node { /* private fields */ }
Expand description

Node controller.

Implementations§

source§

impl Node

source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Connect to the node, via the socket at the given path.

source

pub fn call<T: DeserializeOwned + Send + 'static>( &self, cmd: Command, timeout: Duration, ) -> Result<LineIter<T>, Error>

Call a command on the node.

source

pub fn announce( &mut self, rid: RepoId, seeds: impl IntoIterator<Item = NodeId>, timeout: Duration, callback: impl FnMut(AnnounceEvent, &HashMap<PublicKey, Duration>) -> ControlFlow<()>, ) -> Result<AnnounceResult, Error>

Announce refs of the given rid to the given seeds. Waits for the seeds to acknowledge the refs or times out if no acknowledgments are received within the given time.

Trait Implementations§

source§

impl Clone for Node

source§

fn clone(&self) -> Node

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Node

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Handle for Node

§

type Sessions = Vec<Session>

The peer sessions type.
§

type Events = LineIter<Event>

§

type Event = Result<Event, Error>

§

type Error = Error

The error returned by all methods.
source§

fn nid(&self) -> Result<NodeId, Error>

Get the local Node ID.
source§

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

Get the node’s bound listen addresses.
source§

fn is_running(&self) -> bool

Check if the node is running.
source§

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

Get the current node configuration.
source§

fn connect( &mut self, nid: NodeId, addr: Address, opts: ConnectOptions, ) -> Result<ConnectResult, Error>

Connect to a peer.
source§

fn disconnect(&mut self, nid: NodeId) -> Result<(), Self::Error>

Disconnect from a peer.
source§

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

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

fn fetch( &mut self, rid: RepoId, from: NodeId, timeout: Duration, ) -> Result<FetchResult, Error>

Fetch a repository from the network.
source§

fn follow(&mut self, nid: NodeId, alias: Option<Alias>) -> Result<bool, Error>

Start following the given peer.
source§

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

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

fn unfollow(&mut self, nid: NodeId) -> Result<bool, Error>

Unfollow the given peer.
source§

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

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

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

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

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

Announce local inventory.
source§

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

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

fn subscribe(&self, timeout: Duration) -> Result<LineIter<Event>, Error>

Subscribe to node events.
source§

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

Query the peer session state.
source§

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

Return debug information as a JSON value.
source§

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

Ask the service to shutdown.

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.