pub struct PairingGate { /* private fields */ }Expand description
Manages the pairing window state and persistent paired host list.
Implementations§
Source§impl PairingGate
impl PairingGate
Sourcepub fn new(persist_path: PathBuf) -> Self
pub fn new(persist_path: PathBuf) -> Self
Create a new pairing gate.
persist_path should point to e.g. .weftos/runtime/paired_hosts.json.
Sourcepub fn load(&self) -> Result<usize, Error>
pub fn load(&self) -> Result<usize, Error>
Load paired hosts from disk. Creates file if missing.
Sourcepub fn open_pairing_window(&self, duration: Duration) -> PairingWindowResult
pub fn open_pairing_window(&self, duration: Duration) -> PairingWindowResult
Open a pairing window for the given duration.
Sourcepub fn is_pairing_open(&self) -> bool
pub fn is_pairing_open(&self) -> bool
Check whether the pairing window is currently open.
Sourcepub fn should_accept_peer(&self, peer_id: &str) -> bool
pub fn should_accept_peer(&self, peer_id: &str) -> bool
Determine whether a peer should be accepted.
Returns true if:
- The peer is already paired, OR
- The pairing window is currently open (and records the peer).
Sourcepub fn paired_hosts(&self) -> Vec<String>
pub fn paired_hosts(&self) -> Vec<String>
List all persistently paired host IDs.
Sourcepub fn unpair(&self, peer_id: &str) -> bool
pub fn unpair(&self, peer_id: &str) -> bool
Remove a previously paired host. Returns true if it was present.
Sourcepub fn persist_path(&self) -> &Path
pub fn persist_path(&self) -> &Path
Return the path used for persistence.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PairingGate
impl RefUnwindSafe for PairingGate
impl Send for PairingGate
impl Sync for PairingGate
impl Unpin for PairingGate
impl UnsafeUnpin for PairingGate
impl UnwindSafe for PairingGate
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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