Add Msg and MsgStore traits

This commit is contained in:
Joscha 2022-06-13 09:22:52 +02:00
parent 84d554dee9
commit bea4ed90e7
4 changed files with 80 additions and 5 deletions

View file

@ -1,5 +1,6 @@
#![warn(clippy::use_self)]
mod traits;
mod ui;
use toss::terminal::Terminal;

16
cove-tui/src/traits.rs Normal file
View file

@ -0,0 +1,16 @@
use async_trait::async_trait;
use chrono::{DateTime, Utc};
pub trait Msg {
type Id;
fn id(&self) -> Self::Id;
fn time(&self) -> DateTime<Utc>;
fn nick(&self) -> String;
fn content(&self) -> String;
}
#[async_trait]
pub trait MsgStore<M: Msg> {
async fn path(room: &str, id: M::Id) -> Vec<M::Id>;
}