pub struct NetworkManager { /* private fields */ }Expand description
Persistent manager for network membership and folder associations.
Implementations§
Source§impl NetworkManager
impl NetworkManager
Sourcepub fn new(path_arg: impl Into<PathBuf>, local_node: PublicKey) -> Result<Self>
pub fn new(path_arg: impl Into<PathBuf>, local_node: PublicKey) -> Result<Self>
Open the network database at path.
§Errors
Returns an error if existing state cannot be read or parsed.
Sourcepub fn create(
&mut self,
name: &str,
options: NetworkOptions,
) -> Result<NetworkId>
pub fn create( &mut self, name: &str, options: NetworkOptions, ) -> Result<NetworkId>
Create and persist a network owned by the local node.
§Errors
Returns an error for an empty/duplicate name or failed persistence.
Sourcepub fn join(&mut self, ticket: NetworkTicket) -> Result<NetworkId>
pub fn join(&mut self, ticket: NetworkTicket) -> Result<NetworkId>
Join and persist the network represented by a ticket.
§Errors
Returns an error if the ticket is for another device or persistence fails.
Sourcepub fn leave(&mut self, id: NetworkId) -> Result<()>
pub fn leave(&mut self, id: NetworkId) -> Result<()>
Leave a network and remove its local state.
§Errors
Returns an error if the network does not exist or persistence fails.
Sourcepub fn invite(
&mut self,
id: NetworkId,
device: PublicKey,
) -> Result<NetworkTicket>
pub fn invite( &mut self, id: NetworkId, device: PublicKey, ) -> Result<NetworkTicket>
Generate a device-bound invitation and add the device as a member.
§Errors
Returns an error if the network does not exist, the local node is not its owner, or persistence fails.
Sourcepub fn invite_any(&self, id: NetworkId) -> Result<NetworkTicket>
pub fn invite_any(&self, id: NetworkId) -> Result<NetworkTicket>
Generate an invitation usable by any device.
§Errors
Returns an error if the network does not exist or the local node is not its owner.
Sourcepub fn kick(&mut self, id: NetworkId, device: &PublicKey) -> Result<()>
pub fn kick(&mut self, id: NetworkId, device: &PublicKey) -> Result<()>
Remove a member from a locally owned network.
§Errors
Returns an error if the network does not exist, authorization fails, the owner is targeted, or persistence fails.
Sourcepub fn add_folder(&mut self, id: NetworkId, folder: NamespaceId) -> Result<()>
pub fn add_folder(&mut self, id: NetworkId, folder: NamespaceId) -> Result<()>
Associate a folder with a network.
§Errors
Returns an error if the network does not exist or persistence fails.
Sourcepub fn remove_folder(
&mut self,
id: NetworkId,
folder: NamespaceId,
) -> Result<()>
pub fn remove_folder( &mut self, id: NetworkId, folder: NamespaceId, ) -> Result<()>
Remove a folder association without changing the folder itself.
§Errors
Returns an error if the network does not exist or persistence fails.
Sourcepub async fn subscribe(
&self,
id: NetworkId,
gossip: &GossipService,
) -> Result<GossipTopic>
pub async fn subscribe( &self, id: NetworkId, gossip: &GossipService, ) -> Result<GossipTopic>
Subscribe to the network’s deterministic gossip topic.
The returned topic must be retained by the caller for membership to remain active.
§Errors
Returns an error if the network does not exist or gossip rejects the subscription.
Sourcepub fn topic(&self, id: NetworkId) -> Result<TopicId>
pub fn topic(&self, id: NetworkId) -> Result<TopicId>
Return the gossip topic associated with a network.
§Errors
Returns an error if the network does not exist.
pub fn list(&self) -> Vec<&Network>
pub fn get(&self, id: &NetworkId) -> Option<&Network>
pub fn get_by_name(&self, name: &str) -> Option<&Network>
Trait Implementations§
Source§impl Clone for NetworkManager
impl Clone for NetworkManager
Source§fn clone(&self) -> NetworkManager
fn clone(&self) -> NetworkManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkManager
impl RefUnwindSafe for NetworkManager
impl Send for NetworkManager
impl Sync for NetworkManager
impl Unpin for NetworkManager
impl UnsafeUnpin for NetworkManager
impl UnwindSafe for NetworkManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more