shitty message client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
468 B

  1. use chrono::prelude::*;
  2. struct NetworkPacket(String);
  3. struct Packet {
  4. packet_type: PacketType,
  5. packet_length: u64,
  6. packet_contents: Vec<u8>,
  7. }
  8. #[repr(u8)]
  9. enum PacketType {
  10. NewMessage = 0,
  11. }
  12. struct NewMessage {
  13. user: String,
  14. contents: String,
  15. timestamp: i64,
  16. }
  17. impl NewMessage {
  18. pub fn new(user: String, contents: String) -> Self {
  19. let timestamp = Utc::now().timestamp();
  20. Self { user, contents, timestamp }
  21. }
  22. }