Browse Source

Added library with common stuff

master
Julio Biason 3 years ago
parent
commit
b6fa29f28f
  1. 1
      ms/Cargo.toml
  2. 10
      ms/shared/Cargo.toml
  3. 19
      ms/shared/src/lib.rs

1
ms/Cargo.toml

@ -1,5 +1,6 @@
[workspace]
members = [
"shared",
"server",
"txtclient",
]

10
ms/shared/Cargo.toml

@ -0,0 +1,10 @@
[package]
name = "shared"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.130", features = ["derive"] }

19
ms/shared/src/lib.rs

@ -0,0 +1,19 @@
use chrono::offset::Utc;
use chrono::DateTime;
use serde::Deserialize;
use serde::Serialize;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
received: DateTime<Utc>,
message: String,
}
impl Message {
pub fn new(message: &str) -> Self {
Self {
received: Utc::now(),
message: message.into(),
}
}
}
Loading…
Cancel
Save