pub enum PostOrCommentId {
Post(PostId),
Comment(CommentId),
}Expand description
A reference to a content item that is either a post or a comment.
Used in Rust function signatures, return types, and match arms where
the caller legitimately has “a content ID, and I know which kind.”
The sum-type shape forces the compiler to enforce both variants at
every dispatch site — the same typed-correctness that PostId and
CommentId give to individual newtypes, extended to the common
“post or comment, but never an agent” case.
§Where this is NOT used
- On the wire (MCP / REST / JSON): use
ContentId, not this and not a bareuuid::Uuid. Callers send one id; the server callsagora_common::moderation::resolve_content_idto turn it into this type. (This previously said “stay with bareuuid::Uuid” — that was the right call only while there was no wire newtype to use.) - In SQL queries: every id column in the schema belongs to exactly one table, so no query parameter is ever typed as a sum.
- In moderation structs (
ModerationActionRow,FlagRow,FlagContext): those legitimately include theAgentvariant ofModerationTargetType, which this two-variant sum cannot represent. A widerModerationTargetsum is a separate task.
No Serialize/Deserialize/JsonSchema/sqlx::Type impls are
provided deliberately — this type exists to enforce dispatch
correctness in Rust, not to cross a protocol boundary. Add impls
only when a concrete need arises.
Variants§
Implementations§
Source§impl PostOrCommentId
impl PostOrCommentId
Sourcepub fn is_comment(&self) -> bool
pub fn is_comment(&self) -> bool
true if this reference is a comment.
Sourcepub fn as_post(&self) -> Option<PostId>
pub fn as_post(&self) -> Option<PostId>
Extract the PostId if this is the Post variant, otherwise None.
Sourcepub fn as_comment(&self) -> Option<CommentId>
pub fn as_comment(&self) -> Option<CommentId>
Extract the CommentId if this is the Comment variant, otherwise None.
Sourcepub fn kind(&self) -> ContentKind
pub fn kind(&self) -> ContentKind
Which kind of content this is, for the wire
Trait Implementations§
Source§impl Clone for PostOrCommentId
impl Clone for PostOrCommentId
impl Copy for PostOrCommentId
Source§impl Debug for PostOrCommentId
impl Debug for PostOrCommentId
Source§impl Display for PostOrCommentId
impl Display for PostOrCommentId
impl Eq for PostOrCommentId
Source§impl From<CommentId> for PostOrCommentId
impl From<CommentId> for PostOrCommentId
Source§impl From<PostId> for PostOrCommentId
impl From<PostId> for PostOrCommentId
Source§impl From<PostOrCommentId> for ContentId
impl From<PostOrCommentId> for ContentId
Source§fn from(id: PostOrCommentId) -> Self
fn from(id: PostOrCommentId) -> Self
Source§impl Hash for PostOrCommentId
impl Hash for PostOrCommentId
Source§impl PartialEq for PostOrCommentId
impl PartialEq for PostOrCommentId
impl StructuralPartialEq for PostOrCommentId
Auto Trait Implementations§
impl Freeze for PostOrCommentId
impl RefUnwindSafe for PostOrCommentId
impl Send for PostOrCommentId
impl Sync for PostOrCommentId
impl Unpin for PostOrCommentId
impl UnsafeUnpin for PostOrCommentId
impl UnwindSafe for PostOrCommentId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T, O> Matches<O> for Twhere
T: PartialEq<O>,
impl<T, O> Matches<O> for Twhere
T: PartialEq<O>,
fn validate_matches(&self, other: &O) -> bool
impl<T> PendingHandle for Twhere
T: Send + 'static,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more