Add constructors for ID types

This commit is contained in:
D. Scott Boggs 2023-01-09 08:26:13 -05:00 committed by Scott Boggs
parent 876ac3b985
commit fcc2035b46
8 changed files with 48 additions and 0 deletions

View File

@ -65,6 +65,12 @@ impl AsRef<str> for AccountId {
}
}
impl AccountId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
/// A single name: value pair from a user's profile
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
pub struct MetadataField {

View File

@ -35,6 +35,12 @@ impl AsRef<str> for AttachmentId {
}
}
impl AttachmentId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
/// Information about the attachment itself.
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
pub struct Meta {

View File

@ -62,6 +62,12 @@ impl AsRef<str> for FilterId {
}
}
impl FilterId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
/// Represents the various types of Filter contexts
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]

View File

@ -33,6 +33,12 @@ impl AsRef<str> for NotificationId {
}
}
impl NotificationId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
/// The type of notification.
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]

View File

@ -37,6 +37,12 @@ impl AsRef<str> for SubscriptionId {
}
}
impl SubscriptionId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
pub mod add_subscription {
use serde::Serialize;

View File

@ -42,3 +42,9 @@ impl AsRef<str> for RelationshipId {
&self.0
}
}
impl RelationshipId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}

View File

@ -21,3 +21,9 @@ impl AsRef<str> for ReportId {
&self.0
}
}
impl ReportId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}

View File

@ -76,6 +76,12 @@ impl AsRef<str> for StatusId {
}
}
impl StatusId {
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
}
/// A mention of another user.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Mention {