#[non_exhaustive]pub struct LinkKeys {
pub local: Keypair,
pub peers: Vec<[u8; 32]>,
}Expand description
One end’s key pair, and the public keys of the other ends it accepts.
use kevy_embedded::{Keypair, LinkKeys};
let keys = LinkKeys::new(Keypair::from_secret([1; 32])).with_peers(vec![[2; 32]]);
assert_eq!(keys.peers.len(), 1);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.local: KeypairThis store’s static key pair.
let keys = kevy_embedded::LinkKeys::new(kevy_embedded::Keypair::from_secret([1; 32]));
assert_ne!(keys.local.public(), [0; 32]);peers: Vec<[u8; 32]>On a replica, the primary keys it trusts, tried in turn until one answers; it needs at least one. On a writer, the replica keys it accepts; empty accepts any replica, still encrypted.
let primary = kevy_embedded::Keypair::from_secret([2; 32]);
let keys = kevy_embedded::LinkKeys::new(kevy_embedded::Keypair::from_secret([1; 32]))
.with_peers(vec![primary.public()]);
assert_eq!(keys.peers[0], primary.public());Implementations§
Source§impl LinkKeys
impl LinkKeys
Sourcepub fn new(local: Keypair) -> Self
pub fn new(local: Keypair) -> Self
This end’s key pair local, with no peers yet. The key has no
default: without it the link authenticates nobody.
let keys = kevy_embedded::LinkKeys::new(kevy_embedded::Keypair::from_secret([1; 32]));
assert!(keys.peers.is_empty());Sourcepub fn with_peers(self, peers: Vec<[u8; 32]>) -> Self
pub fn with_peers(self, peers: Vec<[u8; 32]>) -> Self
Set Self::peers.
let keys = kevy_embedded::LinkKeys::new(kevy_embedded::Keypair::from_secret([1; 32]))
.with_peers(vec![[2; 32], [3; 32]]);
assert_eq!(keys.peers.len(), 2);Trait Implementations§
Auto Trait Implementations§
impl Freeze for LinkKeys
impl RefUnwindSafe for LinkKeys
impl Send for LinkKeys
impl Sync for LinkKeys
impl Unpin for LinkKeys
impl UnsafeUnpin for LinkKeys
impl UnwindSafe for LinkKeys
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