Added a lot of Doc

This commit is contained in:
Hannes 2021-05-13 17:46:45 +02:00
commit d65bf5d97a
3 changed files with 118 additions and 2 deletions

View file

@ -6,7 +6,7 @@ use serde::{Serialize, Deserialize};
#[cfg(test)]
use crate::dh::gen_key_pair;
#[derive(Debug)]
#[derive(Debug, Copy, Clone)]
pub struct Header {
pub public_key: PublicKey,
pub pn: usize, // Previous Chain Length
@ -20,7 +20,9 @@ struct ExHeader {
n: usize
}
// Message Header
impl Header {
#[doc(hidden)]
pub fn new(dh_pair: &DhKeyPair, pn: usize, n: usize) -> Self {
Header {
public_key: dh_pair.public_key,
@ -28,7 +30,7 @@ impl Header {
n,
}
}
#[doc(hidden)]
pub fn concat(&self) -> Vec<u8> {
let ex_header = ExHeader{
public_key: self.public_key.to_bytes(),
@ -61,6 +63,12 @@ impl From<&[u8]> for Header {
}
}
impl Into<Vec<u8>> for Header {
fn into(self) -> Vec<u8> {
self.concat()
}
}
impl PartialEq for Header {
fn eq(&self, other: &Self) -> bool {
if self.public_key == other.public_key