Implement std::format::Display for all Id types
This commit is contained in:
parent
eeac76c750
commit
be39ca6e24
|
@ -4,7 +4,7 @@ use serde::{
|
||||||
de::{self, Deserializer, Unexpected},
|
de::{self, Deserializer, Unexpected},
|
||||||
Deserialize, Serialize,
|
Deserialize, Serialize,
|
||||||
};
|
};
|
||||||
use std::path::PathBuf;
|
use std::{fmt::Display, path::PathBuf};
|
||||||
use time::{serde::iso8601, OffsetDateTime};
|
use time::{serde::iso8601, OffsetDateTime};
|
||||||
|
|
||||||
/// A struct representing an Account.
|
/// A struct representing an Account.
|
||||||
|
@ -71,6 +71,12 @@ impl AccountId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for AccountId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
AccountId: PartialEq<crate::attachment::AttachmentId>,
|
AccountId: PartialEq<crate::attachment::AttachmentId>,
|
||||||
PartialEq<crate::filter::FilterId>,
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Module containing everything related to media attachements.
|
//! Module containing everything related to media attachements.
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct representing a media attachment.
|
/// A struct representing a media attachment.
|
||||||
|
@ -41,6 +43,12 @@ impl AttachmentId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for AttachmentId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
AttachmentId: PartialEq<crate::account::AccountId>,
|
AttachmentId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::filter::FilterId>,
|
PartialEq<crate::filter::FilterId>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{de::Visitor, Deserialize, Deserializer, Serialize};
|
use serde::{de::Visitor, Deserialize, Deserializer, Serialize};
|
||||||
use time::{serde::iso8601, OffsetDateTime};
|
use time::{serde::iso8601, OffsetDateTime};
|
||||||
|
|
||||||
|
@ -68,6 +70,12 @@ impl FilterId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for FilterId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
FilterId: PartialEq<crate::account::AccountId>,
|
FilterId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents a `mention` used in a status
|
/// Represents a `mention` used in a status
|
||||||
|
@ -30,6 +32,12 @@ impl MentionId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for MentionId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
Mention: PartialEq<crate::account::AccountId>,
|
Mention: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Module containing all info about notifications.
|
//! Module containing all info about notifications.
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use super::{account::Account, status::Status};
|
use super::{account::Account, status::Status};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::{serde::iso8601, OffsetDateTime};
|
use time::{serde::iso8601, OffsetDateTime};
|
||||||
|
@ -39,6 +41,12 @@ impl NotificationId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for NotificationId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
NotificationId: PartialEq<crate::account::AccountId>,
|
NotificationId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Represents the `alerts` key of the `Subscription` object
|
/// Represents the `alerts` key of the `Subscription` object
|
||||||
|
@ -43,6 +45,12 @@ impl SubscriptionId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for SubscriptionId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
SubscriptionId: PartialEq<crate::account::AccountId>,
|
SubscriptionId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
//! module containing everything relating to a relationship with
|
//! module containing everything relating to a relationship with
|
||||||
//! another account.
|
//! another account.
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct containing information about a relationship with another account.
|
/// A struct containing information about a relationship with another account.
|
||||||
|
@ -48,6 +50,11 @@ impl RelationshipId {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Display for RelationshipId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
RelationshipId: PartialEq<crate::account::AccountId>,
|
RelationshipId: PartialEq<crate::account::AccountId>,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! module containing information about a finished report of a user.
|
//! module containing information about a finished report of a user.
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A struct containing info about a report.
|
/// A struct containing info about a report.
|
||||||
|
@ -28,6 +30,12 @@ impl ReportId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for ReportId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
ReportId: PartialEq<crate::account::AccountId>,
|
ReportId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Module containing all info relating to a status.
|
//! Module containing all info relating to a status.
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use super::prelude::*;
|
use super::prelude::*;
|
||||||
use crate::{card::Card, visibility::Visibility};
|
use crate::{card::Card, visibility::Visibility};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -82,6 +84,12 @@ impl StatusId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for StatusId {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static_assertions::assert_not_impl_any!(
|
static_assertions::assert_not_impl_any!(
|
||||||
StatusId: PartialEq<crate::account::AccountId>,
|
StatusId: PartialEq<crate::account::AccountId>,
|
||||||
PartialEq<crate::attachment::AttachmentId>,
|
PartialEq<crate::attachment::AttachmentId>,
|
||||||
|
|
Loading…
Reference in New Issue