Wrap status id in helper type
This wrapper type ensures that the status id cannot accidentially be compared to some other string that represents something entirely else. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
10ec4dc81f
commit
97ae0973c3
|
@ -9,7 +9,7 @@ use time::{serde::iso8601, OffsetDateTime};
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct Status {
|
pub struct Status {
|
||||||
/// The ID of the status.
|
/// The ID of the status.
|
||||||
pub id: String,
|
pub id: StatusId,
|
||||||
/// A Fediverse-unique resource ID.
|
/// A Fediverse-unique resource ID.
|
||||||
pub uri: String,
|
pub uri: String,
|
||||||
/// URL to the status page (can be remote)
|
/// URL to the status page (can be remote)
|
||||||
|
@ -65,6 +65,17 @@ pub struct Status {
|
||||||
pub pinned: Option<bool>,
|
pub pinned: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wrapper type for a status ID string
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
#[serde(transparent)]
|
||||||
|
pub struct StatusId(String);
|
||||||
|
|
||||||
|
impl AsRef<str> for StatusId {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A mention of another user.
|
/// A mention of another user.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct Mention {
|
pub struct Mention {
|
||||||
|
|
Loading…
Reference in New Issue