zulip_api/api/user.rs
1use zeroize::Zeroize;
2
3/// Represents a Zulip API user used to authenticate to the service.
4#[derive(Clone, Debug, Eq, PartialEq, Zeroize)]
5pub struct User(String);
6
7impl User {
8 /// Creates a new [User].
9 pub const fn new() -> Self {
10 Self(String::new())
11 }
12
13 /// Gets the string representation of the [User].
14 pub fn as_str(&self) -> &str {
15 self.0.as_str()
16 }
17}
18
19impl Default for User {
20 fn default() -> Self {
21 Self::new()
22 }
23}
24
25impl From<&str> for User {
26 fn from(val: &str) -> Self {
27 Self(val.into())
28 }
29}
30
31impl From<String> for User {
32 fn from(val: String) -> Self {
33 Self(val)
34 }
35}