pub struct ContentId(/* private fields */);Expand description
An unresolved reference to a content item — a post or a comment, not yet known which.
This is the wire type. A client citing content sends one UUID and
does not know, or need to know, which table it lives in; the server
resolves it with agora_common::moderation::resolve_content_id,
which returns the PostOrCommentId sum type below.
So the two are a pair, and the distinction is the point:
ContentId— “an id someone handed us.” Crosses protocol boundaries, serializes transparently as a bare UUID string, and carries no claim about what it points at. May not resolve at all.PostOrCommentId— “an id we have resolved.” Rust-internal, never on the wire, and its variants force every dispatch site to handle both kinds.
Resolve at the boundary, then work with the sum type. A
ContentId that has been resolved should not be passed on as a
ContentId.
Implementations§
Trait Implementations§
Source§impl ContentField for ContentId
impl ContentField for ContentId
impl Copy for ContentId
Source§impl<'de> Deserialize<'de> for ContentId
impl<'de> Deserialize<'de> for ContentId
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl Eq for ContentId
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<ContentId> for ContentIdPrefix
impl From<ContentId> for ContentIdPrefix
Source§impl From<ContentId> for ContentTarget
impl From<ContentId> for ContentTarget
Source§impl From<ContentId> for ContentRef
impl From<ContentId> for ContentRef
Source§impl From<PostId> for ContentId
A ContentId can be produced from anything already known to be
content — narrowing to “an id” from “an id we resolved” is always
sound. The reverse needs a database lookup and is
resolve_content_id’s job, which is why there is no From for it.
impl From<PostId> for ContentId
A ContentId can be produced from anything already known to be
content — narrowing to “an id” from “an id we resolved” is always
sound. The reverse needs a database lookup and is
resolve_content_id’s job, which is why there is no From for it.
Source§impl From<PostOrCommentId> for ContentId
impl From<PostOrCommentId> for ContentId
Source§fn from(id: PostOrCommentId) -> Self
fn from(id: PostOrCommentId) -> Self
Source§impl FromStr for ContentId
Every id round-trips through its own Display.
impl FromStr for ContentId
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.
Source§impl Ord for ContentId
impl Ord for ContentId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ContentId
impl PartialOrd for ContentId
impl StructuralPartialEq for ContentId
Auto Trait Implementations§
impl Freeze for ContentId
impl RefUnwindSafe for ContentId
impl Send for ContentId
impl Sync for ContentId
impl Unpin for ContentId
impl UnsafeUnpin for ContentId
impl UnwindSafe for ContentId
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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