pub struct Record { /* private fields */ }Expand description
A signed DHT record containing peer discovery information.
Records are timestamped, signed, and include content about active peers and recent messages for bubble detection and message overlap merging.
Implementations§
Source§impl Record
 
impl Record
Sourcepub fn sign<'a>(
    topic: [u8; 32],
    unix_minute: u64,
    node_id: [u8; 32],
    record_content: impl Serialize + Deserialize<'a>,
    signing_key: &SigningKey,
) -> Result<Self>
 
pub fn sign<'a>( topic: [u8; 32], unix_minute: u64, node_id: [u8; 32], record_content: impl Serialize + Deserialize<'a>, signing_key: &SigningKey, ) -> Result<Self>
Create and sign a new record.
Sourcepub fn from_bytes(buf: Vec<u8>) -> Result<Self>
 
pub fn from_bytes(buf: Vec<u8>) -> Result<Self>
Deserialize from bytes.
Sourcepub fn verify(
    &self,
    actual_topic: &[u8; 32],
    actual_unix_minute: u64,
) -> Result<()>
 
pub fn verify( &self, actual_topic: &[u8; 32], actual_unix_minute: u64, ) -> Result<()>
Verify signature against topic and timestamp.
Sourcepub fn encrypt(&self, encryption_key: &SigningKey) -> EncryptedRecord
 
pub fn encrypt(&self, encryption_key: &SigningKey) -> EncryptedRecord
Encrypt record with HPKE.
Source§impl Record
 
impl Record
Sourcepub fn unix_minute(&self) -> u64
 
pub fn unix_minute(&self) -> u64
Get the Unix minute timestamp.
Sourcepub fn content<'a, T: Deserialize<'a>>(&'a self) -> Result<T>
 
pub fn content<'a, T: Deserialize<'a>>(&'a self) -> Result<T>
Deserialize the record content.
Trait Implementations§
impl Eq for Record
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnwindSafe for Record
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> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Compare self to 
key and return true if they are equal.