cryptgeon/src/note/model.rs

26 lines
551 B
Rust
Raw Normal View History

2021-05-01 12:39:40 +02:00
use bs62;
use ring::rand::SecureRandom;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)]
pub struct Note {
pub contents: String,
pub views: Option<u8>,
2021-05-02 03:07:08 +02:00
pub expiration: Option<u64>,
2021-05-01 12:39:40 +02:00
}
#[derive(Serialize, Deserialize, Clone)]
2021-05-03 12:21:51 +02:00
pub struct NoteInfo {}
2021-05-01 12:39:40 +02:00
2021-05-02 03:07:08 +02:00
#[derive(Serialize, Deserialize, Clone)]
pub struct NotePublic {
pub contents: String,
}
2021-05-01 12:39:40 +02:00
pub fn generate_id() -> String {
let mut id: [u8; 64] = [0; 64];
let sr = ring::rand::SystemRandom::new();
let _ = sr.fill(&mut id);
return bs62::encode_data(&id);
}