pub enum EventContentState {
Missing {
last_fetch_attempt: Option<Timestamp>,
fetch_attempt_count: u16,
next_fetch_attempt: Timestamp,
},
Deleted {
deleted_by: ShortEventId,
},
Pruned,
Invalid,
}Expand description
Per-event content processing state stored in events_content_state table.
This enum tracks the content processing lifecycle for each event:
§State Transitions
Event inserted ──► Missing ──► (no entry) ──► Deleted/Pruned
│ │
│ └─ Content processed successfully
│ (side effects applied)
│
├─ Can also go directly to Deleted/Pruned
│
└─► Invalid ──► DeletedNote: Events with content_len == 0 skip the Missing state entirely. They
go straight to “no entry” (processed) unless they start in Deleted.
§Interpretation
-
No entry in table: Content has been processed for this event. This is the normal state after successful content processing. Side effects (reply counts, follow updates, etc.) have been applied. Also the state for events with no content (
content_len == 0) unless they start inDeleted. -
Missing: Event was inserted but content hasn’t been received or processed yet. The event’s content side effects have NOT been applied. -
Invalid: Content was received but failed validation (e.g. CBOR deserialization). RC has been decremented. Content bytes are discarded. -
Deleted/Pruned: Content is unwanted. RC has been decremented. An eligible Deleted social-post edit may still contribute immutable replacement metadata without ordinary content processing.
§Idempotency Guarantee
The Missing state ensures content processing is idempotent:
process_event_content_txchecks forMissingbefore processing- If
Missing→ process content, then remove the marker - If no entry → skip (already processed)
- If
Deleted/Pruned/Invalid→ skip ordinary processing; the narrow Deleted social-post lineage exception remains idempotent table insertion
This prevents duplicate side effects (e.g., incrementing reply_count twice) when the same content is received multiple times for the same event.
Variants§
Missing
Content has not been received/processed yet for this event.
This state is set when an event with content_len > 0 is inserted
(in insert_event_tx). Events with content_len == 0 skip this state,
going directly to processed or Deleted.
When process_event_content_tx runs and sees this state:
- It processes the content (applies side effects)
- Stores content in
content_storeif not already there - Removes this
Missingmarker (deletes entry from table)
After processing, the event will have NO entry in
events_content_state, indicating content was successfully
processed.
When the event has a current events_content_missing row, the
next_fetch_attempt field mirrors the Timestamp component of that
canonical at-most-one (Timestamp, ShortEventId) key, enabling removal
from the table (which requires the full composite key).
Fields
Deleted
Content was deleted by the author via a deletion event.
When a deletion event targets this event’s content:
- This state is set with a reference to the deleting event
- RC is decremented in
content_rc - Content may be garbage collected if RC reaches 0
Fields
deleted_by: ShortEventIdCanonical direct deleter: maximum
(event.timestamp, ShortEventId).
Pruned
Content was pruned locally (e.g., too large to store).
Unlike Deleted, this is a local decision, not an author request.
Used when content exceeds size limits or for storage management.
Invalid
Content was received but failed validation.
The content bytes could not be deserialized for the event’s kind.
RC has been decremented and content bytes are not stored.
A later author deletion can supersede this with Deleted without
another RC decrement.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for EventContentState
impl<'__de, __Context> BorrowDecode<'__de, __Context> for EventContentState
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl Clone for EventContentState
impl Clone for EventContentState
impl Copy for EventContentState
Source§impl Debug for EventContentState
impl Debug for EventContentState
Source§impl<__Context> Decode<__Context> for EventContentState
impl<__Context> Decode<__Context> for EventContentState
Source§impl Encode for EventContentState
impl Encode for EventContentState
impl Eq for EventContentState
Source§impl PartialEq for EventContentState
impl PartialEq for EventContentState
Source§impl Serialize for EventContentState
impl Serialize for EventContentState
impl StructuralPartialEq for EventContentState
Auto Trait Implementations§
impl Forget for EventContentState
impl Freeze for EventContentState
impl Move for EventContentState
impl RefUnwindSafe for EventContentState
impl Send for EventContentState
impl Sync for EventContentState
impl Unpin for EventContentState
impl UnsafeUnpin for EventContentState
impl UnwindSafe for EventContentState
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
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<F, T> ExpectFrom<F> for T
impl<F, T> ExpectFrom<F> for T
fn expect_from(other: F) -> T
Source§impl<F, I> ExpectInto<I> for Fwhere
I: ExpectFrom<F>,
impl<F, I> ExpectInto<I> for Fwhere
I: ExpectFrom<F>,
fn expect_into(self) -> I
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more