#[non_exhaustive]pub struct ReplicaSecurity {
pub local: Keypair,
pub primary_key: [u8; 32],
}Expand description
What a replica needs to open a secure link: its own key, and the primary’s public key it will accept.
use kevy_noise::Keypair;
use kevy_replicate::replica::ReplicaSecurity;
let sec = ReplicaSecurity::new(Keypair::from_secret([2; 32]), [9; 32]);
assert_eq!(sec.primary_key, [9; 32]);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: KeypairThe replica’s static key pair; a primary with replica_keys set
lists its public half.
let sec = kevy_replicate::replica::ReplicaSecurity::new(kevy_noise::Keypair::from_secret([2; 32]), [9; 32]);
assert_ne!(sec.local.public(), [0; 32]);primary_key: [u8; 32]The primary’s public key; a primary holding any other key cannot complete the handshake.
let primary = kevy_noise::Keypair::from_secret([1; 32]);
let sec = kevy_replicate::replica::ReplicaSecurity::new(
kevy_noise::Keypair::from_secret([2; 32]),
primary.public(),
);
assert_eq!(sec.primary_key, primary.public());Implementations§
Source§impl ReplicaSecurity
impl ReplicaSecurity
Sourcepub fn new(local: Keypair, primary_key: [u8; 32]) -> Self
pub fn new(local: Keypair, primary_key: [u8; 32]) -> Self
The replica’s key pair local and the public key the primary must
present. Neither has a default: without them the link authenticates
nobody.
let sec = kevy_replicate::replica::ReplicaSecurity::new(
kevy_noise::Keypair::from_secret([2; 32]),
[7; 32],
);
assert_eq!(sec.primary_key, [7; 32]);Trait Implementations§
Source§impl Clone for ReplicaSecurity
impl Clone for ReplicaSecurity
Auto Trait Implementations§
impl Freeze for ReplicaSecurity
impl RefUnwindSafe for ReplicaSecurity
impl Send for ReplicaSecurity
impl Sync for ReplicaSecurity
impl Unpin for ReplicaSecurity
impl UnsafeUnpin for ReplicaSecurity
impl UnwindSafe for ReplicaSecurity
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