ruma_client_api/profile/
static_profile_field.rs

1#![allow(clippy::exhaustive_structs)]
2
3use ruma_common::OwnedMxcUri;
4use serde::{de::DeserializeOwned, Serialize};
5
6/// Trait implemented by types representing a field in a user's [profile] having a statically-known
7/// name.
8///
9/// [profile]: https://spec.matrix.org/latest/client-server-api/#profiles
10pub trait StaticProfileField {
11    /// The type for the value of the field.
12    type Value: Sized + Serialize + DeserializeOwned;
13
14    /// The string representation of this field.
15    const NAME: &str;
16}
17
18/// The user's avatar URL.
19#[derive(Debug, Clone, Copy)]
20pub struct AvatarUrl;
21
22impl StaticProfileField for AvatarUrl {
23    type Value = OwnedMxcUri;
24    const NAME: &str = "avatar_url";
25}
26
27/// The user's display name.
28#[derive(Debug, Clone, Copy)]
29pub struct DisplayName;
30
31impl StaticProfileField for DisplayName {
32    type Value = String;
33    const NAME: &str = "displayname";
34}
35
36/// The user's time zone.
37#[derive(Debug, Clone, Copy)]
38pub struct TimeZone;
39
40impl StaticProfileField for TimeZone {
41    type Value = String;
42    const NAME: &str = "m.tz";
43}