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 {
|
2021-12-21 00:15:04 +01:00
|
|
|
pub meta: String,
|
2021-05-01 12:39:40 +02:00
|
|
|
pub contents: String,
|
|
|
|
pub views: Option<u8>,
|
2021-12-22 14:46:06 +01:00
|
|
|
pub expiration: Option<u32>,
|
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 {
|
2021-12-21 00:15:04 +01:00
|
|
|
pub meta: String,
|
2021-05-02 03:07:08 +02:00
|
|
|
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);
|
|
|
|
}
|