Skip to main content

invite

Function invite 

Source
pub fn invite(
    library: &mut Library,
    network: &Network,
    invitation: &Invitation,
    code: &PairingCode,
    confirm: &'_ mut dyn FnMut(&Invitee) -> bool,
    showing: Showing<'_>,
    now: &dyn Fn() -> u64,
    rng: &mut impl CryptoRng,
) -> Result<Invited, NodeError>
Expand description

Invites a user to a shared space, as a replica of an admin of it: announces the code’s first two digits on the network, waits as showing says for a replica to join with the code, shows confirm who asks, and, once it says yes, adds them as a member with the role given, lists the replica that joined, and answers its first sync of the space. network must take connections. The code takes tries as in pair. If the first sync fails, the joiner removes the space while the member stays, and a new invitation of the same device makes it that member again; a device listed already comes back so too. Changes are made at the time now gives when they are made.

§Errors

Returns NodeError::NeverShared for the personal space, NodeError::AdminsOnly if this replica’s member is no admin, NodeError::NoRole for the role none, before the code is shown; NodeError::InvitationExpired if nobody joined in time, the error of the last try if each failed before the code matched, such as NodeError::Sync with SyncError::WrongCode if one typed another code, NodeError::Declined if confirm said no, NodeError::Sync with SyncError::Ended and Reason::HoldsSpace if the joiner holds the space already, NodeError::InvitationFailed if the first sync failed, and other errors if the network or the library fails.