pub struct Policy { /* private fields */ }Expand description
The whole allowlist. Parsing validates every key up front, so a malformed
peers.json fails loudly at startup rather than silently at message time.
Implementations§
Source§impl Policy
impl Policy
pub fn load(path: &Path) -> Result<Self>
pub fn parse(raw: &str) -> Result<Self>
Sourcepub fn peer(&self, id: AgentId) -> Option<&Peer>
pub fn peer(&self, id: AgentId) -> Option<&Peer>
Look up an authenticated sender. None ⇒ not on the allowlist ⇒ drop.
Sourcepub fn resolve(&self, petname: &str) -> Result<AgentId>
pub fn resolve(&self, petname: &str) -> Result<AgentId>
Resolve a petname to a key for outbound sends.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn add(&mut self, petname: &str, key_b64: &str) -> Result<()>
pub fn add(&mut self, petname: &str, key_b64: &str) -> Result<()>
Admit a peer (or no-op if the same petname→key pair is already present).
Rejects a petname already bound to a different key, or a key already
held under a different petname — either would make the authenticated
sender lookup ambiguous, exactly as Policy::parse guards against.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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