add: auto_method macro
This commit is contained in:
parent
bb682add85
commit
1d9a96ae69
4 changed files with 184 additions and 117 deletions
|
@ -1,4 +1,5 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tetratto_shared::{snow::AlmostSnowflake, unix_epoch_timestamp};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct JournalPage {
|
||||
|
@ -17,6 +18,24 @@ pub struct JournalPage {
|
|||
pub write_access: JournalPageWriteAccess,
|
||||
}
|
||||
|
||||
impl JournalPage {
|
||||
/// Create a new [`JournalPage`].
|
||||
pub fn new(title: String, prompt: String, owner: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
title,
|
||||
prompt,
|
||||
owner,
|
||||
read_access: JournalPageReadAccess::default(),
|
||||
write_access: JournalPageWriteAccess::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Who can read a [`JournalPage`].
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum JournalPageReadAccess {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue