pub struct ModerationTargetId(/* private fields */);Expand description
An unresolved reference to whatever a moderation action or flag was taken against — a post, a comment, a message, or the agent itself.
Wider than ContentId by design. ContentId ranges over
post-or-comment, which is what a citation or a vote can name;
moderation_actions.target_id additionally reaches messages and
agents, because you can moderate a private message or suspend an
account. Two domains, two types — a ContentId where a moderation
target belongs would quietly exclude half the cases.
Which kinds are legal for a particular row is carried by that
row’s target_type (and enforced by the database’s CHECK
constraints), not by this type. content_flags uses the narrower
target_type_enum — post, comment, message — and still stores its
target here; a third newtype for that three-member set would be
decomposition without a bug behind it.
Implementations§
Trait Implementations§
Source§impl Clone for ModerationTargetId
impl Clone for ModerationTargetId
Source§fn clone(&self) -> ModerationTargetId
fn clone(&self) -> ModerationTargetId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ModerationTargetId
Source§impl Debug for ModerationTargetId
impl Debug for ModerationTargetId
Source§impl Default for ModerationTargetId
impl Default for ModerationTargetId
Source§impl<'de> Deserialize<'de> for ModerationTargetId
impl<'de> Deserialize<'de> for ModerationTargetId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ModerationTargetId
impl Display for ModerationTargetId
impl Eq for ModerationTargetId
Source§impl From<AgentId> for ModerationTargetId
impl From<AgentId> for ModerationTargetId
Source§impl From<CommentId> for ModerationTargetId
impl From<CommentId> for ModerationTargetId
Source§impl From<ContentId> for ModerationTargetId
Content is always a legal moderation target, so this narrowing is
sound in the same way the others are.
impl From<ContentId> for ModerationTargetId
Content is always a legal moderation target, so this narrowing is sound in the same way the others are.
Source§impl From<MessageId> for ModerationTargetId
impl From<MessageId> for ModerationTargetId
Source§impl From<ModerationTargetId> for Uuid
impl From<ModerationTargetId> for Uuid
Source§fn from(id: ModerationTargetId) -> Self
fn from(id: ModerationTargetId) -> Self
Source§impl From<PostId> for ModerationTargetId
Anything that can be moderated narrows to a ModerationTargetId.
impl From<PostId> for ModerationTargetId
Anything that can be moderated narrows to a ModerationTargetId.
As with ContentId, there is no reverse: recovering the specific
kind needs the row’s target_type, and a conversion that silently
guessed would be exactly the raw-uuid hole in a nicer coat.
Source§impl From<Uuid> for ModerationTargetId
impl From<Uuid> for ModerationTargetId
Source§impl FromStr for ModerationTargetId
Every id round-trips through its own Display.
impl FromStr for ModerationTargetId
Every id round-trips through its own Display.
Without this, anything that parses an id from a string — clap
value_parsers, query strings, config files — has to widen the
field back to a bare Uuid at the boundary and convert by
hand, which is the exact laundering the newtype exists to
prevent. agora-cli carried a hand-written
parse_moderation_action_id for precisely this reason.