From 9dbadb0a3fbb1bb2f89c69cbb07458c9d0bd8d21 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 22 Jun 2022 21:52:07 +0200 Subject: [PATCH] Add constructors for Nick and Send --- cove-tui/src/euph/api/room_cmds.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cove-tui/src/euph/api/room_cmds.rs b/cove-tui/src/euph/api/room_cmds.rs index 02dddd4..f4653e3 100644 --- a/cove-tui/src/euph/api/room_cmds.rs +++ b/cove-tui/src/euph/api/room_cmds.rs @@ -46,6 +46,14 @@ pub struct Nick { pub name: String, } +impl Nick { + pub fn new(name: S) -> Self { + Self { + name: name.to_string(), + } + } +} + /// Confirms the [`Nick`] command. /// /// Returns the session's former and new names (the server may modify the @@ -98,6 +106,22 @@ pub struct Send { pub parent: Option, } +impl Send { + pub fn new(content: S) -> Self { + Self { + content: content.to_string(), + parent: None, + } + } + + pub fn reply(parent: Snowflake, content: S) -> Self { + Self { + content: content.to_string(), + parent: Some(parent), + } + } +} + /// The message that was sent. /// /// this includes the message id, which was populated by the server.