Skip to main content

Service

Struct Service 

Source
pub struct Service {
    services: Arc<OnceServices>,
    db: Data,
    pub mutex_insert: MutexMap<OwnedRoomId, ()>,
}
Expand description

Provides persistent event lookup, insertion, and room timeline traversal.

Accepted events and outliers occupy separate maps while event IDs point to accepted timeline positions. A per-room insertion lock serializes the final mutation stage after federation and state work.

Fields§

§services: Arc<OnceServices>§db: Data§mutex_insert: MutexMap<OwnedRoomId, ()>

Serializes timeline insertion as the leaf per-room operation.

Acquire it after any federation or state mutex held for the same room. Never acquire either outer mutex while holding this guard.

Implementations§

Source§

impl Service

Source

pub(crate) async fn append_incoming_pdu<'a, Leafs>( &'a self, __arg1: Incoming<'a, Leafs>, ) -> Result<Option<RawPduId>>
where Leafs: Iterator<Item = &'a EventId> + Send + 'a,

Appends an incoming event with its locally resolved state snapshot.

The snapshot is recorded even when the event is soft-failed. A soft-failed event is not inserted into the accepted timeline, but its predecessors are marked referenced. Only a nonempty replacement extremity band is stored; an empty calculation preserves the prior band.

Source§

impl Service

Source

pub async fn append_pdu<'a, Leafs>( &'a self, pdu: &'a PduEvent, pdu_json: CanonicalJsonObject, leafs: Leafs, shortstatehash: Option<ShortStateHash>, state_lock: &'a RoomMutexGuard, ) -> Result<RawPduId>
where Leafs: Iterator<Item = &'a EventId> + Send + 'a,

Persists an authenticated event and applies its timeline side effects.

This method performs no authentication. The accepted row, event mapping, outlier removal, and timestamp index are committed together, but later cache, indexing, notification, and membership work is not part of that transaction, so an error can be returned after the event is stored. Any prepared current state is installed before the event’s stream count retires, including when a later timeline effect returns an error.

Source§

impl Service

Source

async fn read_replaced( &self, pdu: &PduEvent, pdu_json: CanonicalJsonObject, ) -> Result<(CanonicalJsonObject, Option<PduCount>)>

Fill a state event’s unsigned from the event it replaced, and find the position of the same user’s join that a profile change replaces.

The replaced event is read once from the event’s own state snapshot and is dropped on return, so it holds no place across the append’s later awaits.

Source§

impl Service

Source

async fn prev_state(&self, pdu: &PduEvent, state_key: &str) -> Option<PduEvent>

Source§

impl Service

Source

async fn replaced_join( &self, pdu: &PduEvent, prev_state: Option<&PduEvent>, ) -> Option<PduCount>

Stream position of the same user’s join that a member event replaces, when the event is itself a join, as a profile change is.

prev_state must come from the event’s own state snapshot, never the state cache, which a forced replay may have moved ahead of this append. Any other event yields None, as does a replaced join without a readable position, which a failed read logs.

Source§

impl Service

Source

async fn append_pdu_effects( &self, __arg1: Appended<'_>, state_lock: &RoomMutexGuard, ) -> Result

Source§

impl Service

Source

async fn append_member_effects( &self, pdu: &PduEvent, replaced_join: Option<PduCount>, count: PduCount, ) -> Result

Record the membership transition an m.room.member event carries.

The cache is written here rather than off the resolved state so that a user who is invited or knocked and leaves immediately still leaves the earlier event on record for auth. A join that replaced the same user’s join is a profile change, which keeps the user’s recorded join position.

Source§

impl Service

Source

async fn append_message_effects( &self, pdu_id: &RawPduId, pdu: &PduEvent, shortroomid: ShortRoomId, ) -> Result

Index an m.room.message event’s body, and queue it when it is an admin command.

The queued command carries the event’s sender, so a handler can tell who issued it, and the event’s id, which its response replies to.

Source§

impl Service

Source

fn append_pdu_json( &self, pdu_id: &RawPduId, pdu: &PduEvent, json: &CanonicalJsonObject, )

Source§

impl Service

Source

pub async fn backfill_if_required( &self, room_id: &RoomId, from: PduCount, ) -> Result

Attempts federation backfill when a request reaches local history’s edge.

Backfill is skipped after the create event and for effectively empty rooms that are not world-readable. No candidate, a remote fetch failure, or an empty accepted chunk is treated as a successful best-effort outcome.

Source§

impl Service

Source

async fn backfill_candidates(&self, room_id: &RoomId) -> Candidates

Source§

impl Service

Source

pub async fn get_event_id_near_ts_with_fallback( &self, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> Result<(MilliSecondsSinceUnixEpoch, OwnedEventId)>

Finds the nearest event to a timestamp with a federation fallback.

The local answer is retained unless a closer remote claim can be ingested. The ingested event must belong to this room and its actual timestamp must remain on the requested side of the query.

Source§

impl Service

Source

async fn is_start_edge_hit(&self, room_id: &RoomId, event_id: &EventId) -> bool

Source§

impl Service

Source

async fn backfill_event( &self, room_id: &RoomId, event_id: &EventId, origin: &ServerName, ) -> Result<PduEvent>

Source§

impl Service

Source

pub async fn fetch_remote_event( &self, room_id: &RoomId, event_id: &EventId, ) -> Result

Fetches one remote event and persists it through the backfill path.

Fetcher checks are disabled only for retrieval; backfill_pdu performs signature, hash, and authorization validation. An event already accepted completes successfully without another insertion, while a stored outlier is still validated and promoted.

Source§

impl Service

Source

pub async fn backfill_pdu( &self, room_id: &RoomId, origin: &ServerName, pdu: Box<RawJsonValue>, ) -> Result<bool>

Validates and inserts one remotely supplied event as backfilled history.

An already accepted duplicate returns false without insertion. A new event or stored outlier receives a negative backfill count, moves to accepted storage, updates its timestamp and ID indexes, and adds searchable message or topic content.

Source§

impl Service

Source

fn prepend_backfill_pdu( &self, pdu_id: &RawPduId, room_id: &RoomId, event_id: &EventId, origin_server_ts: u64, json: &CanonicalJsonObject, )

Source§

impl Service

Source

pub fn build_and_append_pdu<'a>( &'a self, pdu_builder: PduBuilder, sender: &'a UserId, room_id: &'a RoomId, state_lock: &'a RoomMutexGuard, ) -> impl Future<Output = Result<OwnedEventId>> + Send + 'a

Builds, signs, validates, and persists a locally authored room event.

The caller’s state guard serializes state derivation and advancement while the event is inserted into the accepted timeline. Federation enqueue occurs after persistence, so its failure can be returned after the event and room state have already been stored.

Source§

impl Service

Source

pub async fn build_and_store_pdu( &self, pdu_builder: PduBuilder, sender: &UserId, room_id: &RoomId, state_lock: &RoomMutexGuard, ) -> Result<(OwnedEventId, Result)>

Builds and persists a locally authored room event, telling a failure after storage apart from one before it.

An outer error means no timeline row for the event could be found after the failure. An inner error comes from work done after the event entered the timeline, such as its side effects or federation enqueue, so the event exists under the returned ID.

Source§

impl Service

Source

pub async fn build_and_append_create_pdu( &self, content: CanonicalJsonObject, sender: &UserId, timestamp: Option<MilliSecondsSinceUnixEpoch>, expected_room_id: Option<&str>, ) -> Result<OwnedEventId>

Builds, signs, and persists a room’s create event under the placeholder room lock every hashed-ID create takes.

A client that fixed the timestamp or named the room ID it expects has predicted the hash, so a collision is refused. A collision on a server-chosen timestamp is retried once with a nonce key in the content.

Source§

impl Service

Source

pub async fn build_and_append_create_pdu_with( &self, content: CanonicalJsonObject, sender: &UserId, timestamp: Option<MilliSecondsSinceUnixEpoch>, collision: Collision<'_>, ) -> Result<OwnedEventId>

Builds, signs, and persists a room’s create event as build_and_append_create_pdu does, under an explicit collision policy.

A timestamp of None takes the server’s clock, and one more than a minute ahead of it is refused. collision decides what a room ID an earlier create already took does to this one.

Source§

impl Service

Source

async fn hash_create_unique( &self, inputs: &CreateInputs<'_>, content: CanonicalJsonObject, collision: Collision<'_>, ) -> Result<(PduEvent, CanonicalJsonObject)>

Source§

impl Service

Source

async fn hash_create_content( &self, __arg1: &CreateInputs<'_>, content: &CanonicalJsonObject, ) -> Result<(PduEvent, CanonicalJsonObject)>

Source§

impl Service

Source

async fn append_signed_pdu( &self, pdu: PduEvent, pdu_json: CanonicalJsonObject, sender: &UserId, state_lock: &RoomMutexGuard, ) -> Result<OwnedEventId>

Validates and persists an event built by create_hash_and_sign_event under the state guard it was built under.

The event is checked, signed by the room’s policy server, and stored before it is queued for federation, so a queueing failure is returned for an event already in the room.

Source§

impl Service

Source

async fn with_policy_signature( &self, pdu_json: CanonicalJsonObject, pdu: &PduEvent, ) -> Result<CanonicalJsonObject>

Has the room’s policy server, if any, sign an event before it is federated.

Per MSC4284 a refusal is an error, while a transport failure lets the event go out unsigned.

Source§

impl Service

Source

async fn reserve_room_id(&self, room_id: &RoomId) -> Result

Allocates the short ID of a room named by its create event’s hash.

A short ID already present belongs to an earlier create event with the same hash, so the new room is refused rather than merged into it.

Source§

impl Service

Source

async fn room_id_taken(&self, room_id: &RoomId) -> Result<bool>

Source§

impl Service

Source

async fn sanitize_member_authorisation( &self, pdu_builder: PduBuilder, room_id: &RoomId, ) -> Result<PduBuilder>

Source§

impl Service

Source

async fn check_pdu_for_admin_room<Pdu>( &self, pdu: &Pdu, sender: &UserId, ) -> Result
where Pdu: Event,

Source§

impl Service

Source

async fn check_admin_room_member<Pdu>( &self, pdu: &Pdu, sender: &UserId, ) -> Result
where Pdu: Event,

Refuses a leave or ban that would take the server user, or the last active admin, out of the admins room.

Deactivation runs the same last-admin check under this room’s state lock; see lock_admin_room.

Source§

impl Service

Source

async fn check_redaction_authorized<Pdu>(&self, pdu: &Pdu) -> Result
where Pdu: Event,

Source§

impl Service

Source

pub(crate) async fn get_checked<T>( &self, event_id: &EventId, ) -> Result<Mapped<T>>
where T: for<'de> Deserialize<'de>,

Deserializes an event from accepted or outlier storage as get does, following its timeline mapping untrusted.

The accepted branch reads the mapping and then the row, while the outlier copy is read beside it from the start, and the first found wins, as there. A mapping that does not decode ends the race as Mapped::Damaged at the point where get panics, so an outlier copy found before it is returned and the damage goes unreported, as get returns that copy. When both fail, the accepted error is returned unless its row is missing.

Source§

impl Service

Source

pub(crate) async fn get_checked_keeping<T, K>( &self, event_id: &EventId, keep: K, ) -> Result<Mapped<T>>
where T: for<'de> Deserialize<'de>, K: FnOnce(&Error) -> bool,

Deserializes an event from accepted storage, or from outlier storage when that fails, following its timeline mapping untrusted.

This is the read get_room_version makes through get_non_outlier and then get_outlier: the accepted copy wins whenever it is read, and when both fail keep says whether the accepted error is returned over the outlier’s. A mapping that does not decode is Mapped::Damaged before the outlier is read, where get_non_outlier panics, and a failed or absent mapping fails the accepted read, as there.

Source§

impl Service

Source

async fn pdu_id_checked(&self, event_id: &EventId) -> Mapped<Result<RawPduId>>

Reads an event’s timeline mapping as get_pdu_id does, decoding it untrusted.

A failed or absent read keeps its error, as there, and a mapping that does not decode is Mapped::Damaged where that function panics.

Source§

impl Service

Source

pub(crate) async fn get_from_id_checked<T>( &self, pdu_id: &RawPduId, ) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes an accepted timeline row by PDU id as get_from_id does in a release build.

A debug build of that function panics on a row holding a further record after the event’s, beyond one trailing separator, while this reads such a row as a release build reads it.

Source§

impl Service

Source

async fn get_outlier_checked<T>(&self, event_id: &EventId) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes an event from outlier storage as get_outlier does in a release build.

Like get_from_id_checked, it reads a row holding a further record after the event’s as a release build reads it, where a debug build panics.

Source§

impl Service

Source

pub(crate) async fn pdu_position(&self, event_id: &EventId) -> Result<Position>

Reads where the timeline places an event, decoding the mapping untrusted.

get_pdu_id panics on a mapping that is not a PDU id, which this reports.

Source§

impl Service

Source

pub async fn create_hash_and_sign_event( &self, pdu_builder: PduBuilder, sender: &UserId, room_id: &RoomId, _mutex_lock: &RoomMutexGuard, ) -> Result<(PduEvent, CanonicalJsonObject)>

Builds a canonical signed PDU and its structured representation.

Up to twenty current forward extremities become predecessors, and a non-create event is rejected when no predecessor is available. The event is authorization-checked and formatted under the room version, including the version-specific room-ID rules, but is not persisted here.

Source§

impl Service

Source

async fn compute_prev_events( &self, room_id: &RoomId, event_type: &TimelineEventType, ) -> Result<PrevEvents>

Source§

impl Service

Source

pub async fn delete_pdus(&self, room_id: &RoomId) -> Result

Deletes every accepted timeline row belonging to a room.

Each event’s accepted row, ID mapping, outlier copy, and timestamp index are removed in one transaction. An error stops the scan after any prior events were already removed, and metadata owned by other services is not purged.

Source§

impl Service

Source

pub fn pdus_near_ts( &self, user_id: Option<&UserId>, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> impl Stream<Item = Result<PdusIterItem>> + Send

Streams decoded room events from the timestamp index in one direction.

The timestamp boundary is inclusive. user_id controls sender-only unsigned fields, while event age is always updated. It does not filter which events are yielded.

Source§

impl Service

Source

pub fn pdu_ids_near_ts( &self, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> impl Stream<Item = Result<(MilliSecondsSinceUnixEpoch, PduId)>> + Send

Streams timestamp and PDU-ID pairs from the room timestamp index.

Forward scans begin at the first row at or after the timestamp, while backward scans begin at the first row at or before it. Only rows for the requested room are yielded.

Source§

impl Service

Source

pub fn all_pdus<'a>( &'a self, user_id: &'a UserId, room_id: &'a RoomId, ) -> impl Stream<Item = PdusIterItem> + Send + 'a

Streams all accepted PDUs in a room in forward order.

The requesting user receives sender-only unsigned fields where applicable. Unknown rooms and all per-item storage or decoding errors are suppressed, producing only successfully presented events.

Source§

impl Service

Source

pub fn pdus<'a>( &'a self, user_id: Option<&'a UserId>, room_id: &'a RoomId, from: Option<PduCount>, ) -> impl Stream<Item = Result<PdusIterItem>> + Send + 'a

Streams accepted room events after an optional count in forward order.

The count boundary is exclusive and defaults to the minimum count. The optional user controls presentation only; stream, storage, and decoding errors remain visible to the caller.

Source§

impl Service

Source

pub fn pdus_rev<'a>( &'a self, user_id: Option<&'a UserId>, room_id: &'a RoomId, until: Option<PduCount>, ) -> impl Stream<Item = Result<PdusIterItem>> + Send + 'a

Streams accepted room events before an optional count in reverse order.

The count boundary is exclusive and defaults to the maximum count. The optional user controls presentation only; stream, storage, and decoding errors remain visible to the caller.

Source§

impl Service

Source

pub fn pdus_raw(&self) -> impl Stream<Item = Result<Val<'_>>> + Send

Streams raw JSON values from all accepted timeline rows.

Values borrow the database cursor and must be owned before they are retained across another poll. Storage errors remain in the stream.

Source§

impl Service

Source

pub fn outlier_pdus_raw(&self) -> impl Stream<Item = Result<Val<'_>>> + Send

Streams raw JSON values from all outlier rows.

Values borrow the database cursor and must be owned before they are retained across another poll. Storage errors remain in the stream.

Source§

impl Service

Source

fn each_slice( (pdu_id, pdu): KeyVal<'_>, user_id: Option<&UserId>, ) -> Result<PdusIterItem>

Source§

impl Service

Source

fn each_pdu( (pdu_id, pdu): (RawPduId, PduEvent), user_id: Option<&UserId>, ) -> PdusIterItem

Source§

impl Service

Source

pub async fn purge_history( &self, room_id: &RoomId, until: PduCount, delete_local_events: bool, ) -> Result<usize>

Purges eligible room history strictly before a timeline count.

State events are preserved, and locally sent events remain unless delete_local_events is set. Forward extremities are untouched, while search, relation, and retained-original data are removed for each deleted event; an error can stop the operation after partial progress.

Source§

impl Service

Source

pub async fn redact_pdu<Pdu: Event + Send + Sync>( &self, event_id: &EventId, reason: &Pdu, shortroomid: ShortRoomId, state_lock: &RoomMutexGuard, ) -> Result

Replaces an accepted PDU with its room-version redacted form.

Failure to resolve the event’s accepted PDU ID is treated as a successful no-op. Original retention, search removal, relation deletion, and removal from unread counts occur before the accepted row is replaced, so the operation is not atomic if a later step fails. A redacted thread reply is removed from its root’s m.thread summary (the count, and the latest event when it was the latest) in the same write as the accepted row, which also takes a thread left with no replies off the thread list; a redacted thread root keeps its summary.

Source§

impl Service

Source

pub async fn restore_redaction<Pdu: Event + Send + Sync>( &self, event_id: &EventId, reason: &Pdu, rules: &RedactionRules, _state_lock: &RoomMutexGuard, ) -> Result<bool>

Records an applied redaction on an accepted PDU that does not carry it.

A database migrated from another homeserver implementation can hold an event whose content a redaction already removed but which lacks redacted_because, so it reads as unredacted. When the content already equals its redacted form, the row is rewritten in the form redact_pdu leaves, skipping the steps that need the original content. As with redact_pdu, the latest of several redactions is the one recorded. Returns whether the row was rewritten.

Source§

impl Service

Source

async fn redaction_precedes( &self, recorded: &CanonicalJsonValue, later: &EventId, ) -> Result<bool>

Whether the redaction a row records comes before later in the timeline.

A missing or malformed record, or a missing timeline position, is kept. Other lookup failures are returned to the caller.

Source§

impl Service

Source

pub(crate) async fn redaction_restoration<Pdu: Event + Send + Sync>( &self, event_id: &EventId, reason: &Pdu, rules: &RedactionRules, ) -> Result<Restoration>

Decides as [Service::restore_redaction] does, writing nothing.

No lock is taken, so the answer describes the rows as they stand. Each timeline mapping is decoded without trusting it, and the event’s row is parsed as a release build of the stored-event decoder parses it, without a debug build’s assertion that no further record follows the event’s. So a mapping the primitive panics on reads as malformed and a row that decoder fails on as unreadable; only a failed read is an error.

Source§

impl Service

Source

async fn precedes_checked( &self, recorded: &CanonicalJsonValue, later: &EventId, ) -> Result<Option<bool>>

Whether the redaction a row records comes before later, as redaction_precedes decides it.

Each timeline mapping is decoded untrusted, and None means one does not decode, where that would panic.

Source§

impl Service

Source

pub async fn replace_pdu( &self, pdu_id: &RawPduId, pdu_json: &CanonicalJsonObject, ) -> Result

Replaces the stored JSON of an accepted PDU without changing its ID.

A definite missing-row result is returned as NotFound; otherwise the accepted timeline row is overwritten in place.

Source§

impl Service

Source

pub(super) async fn replace_redacted_pdu( &self, pdu_id: &RawPduId, pdu: &CanonicalJsonObject, root: Option<RedactedRoot>, ) -> Result

Replaces a redacted event and its optional thread root in one batch.

The caller retains the room guard through this write. The root’s thread index changes are part of the same batch.

Source§

impl Service

Source

fn redaction_txn( &self, pdu_id: &RawPduId, pdu: &CanonicalJsonObject, root: Option<&RedactedRoot>, ) -> Txn

Stages a redacted event after its thread root.

The redacted row comes last so it wins when a reply names itself as its root.

Source§

impl Service

Source

async fn require_pdu(&self, pdu_id: &RawPduId) -> Result

Source§

impl Service

Source

pub(super) fn stage_replace_pdu( &self, txn: &mut Txn, pdu_id: &RawPduId, pdu_json: &CanonicalJsonObject, )

Stage replacement of a PDU already loaded under its room’s guard.

The caller retains the guard until the transaction commits.

Source§

impl Service

Source

pub async fn add_verified_outlier( &self, event_id: &EventId, pdu: &CanonicalJsonObject, verified: &Verified, )

Stores a verified federation event as an outlier unless this server’s copy takes precedence.

An accepted event keeps its copy, and so does any stored event whose new copy had to be redacted. A copy whose content matches its hash replaces an outlier, such as one stored from knock state without a hash check.

Source§

impl Service

Source

pub fn add_pdu_outlier(&self, event_id: &EventId, pdu: &CanonicalJsonObject)

Stores an event as an outlier outside the accepted room timeline.

The event is keyed directly by event ID and no accepted-timeline mapping or stream position is created.

Source§

impl Service

Source

pub async fn first_pdu_in_room(&self, room_id: &RoomId) -> Result<PduEvent>

Returns the earliest accepted PDU in a room, backfilled ones included.

Unknown or empty rooms report the underlying stream’s not-found result.

Source§

impl Service

Source

pub async fn first_normal_pdu_in_room( &self, room_id: &RoomId, ) -> Result<PduEvent>

Returns the earliest PDU in a room’s normal timeline.

Backfilled PDUs sort before it but are skipped, because backfill admits events with whatever timestamp their origin claims. Rooms without a normal PDU report not found.

Source§

impl Service

Source

pub async fn latest_pdu_in_room(&self, room_id: &RoomId) -> Result<PduEvent>

Returns the latest accepted PDU in a room.

Presentation removes sender-only transaction metadata because no requesting user is supplied.

Source§

impl Service

Source

pub async fn first_item_in_room( &self, room_id: &RoomId, ) -> Result<(PduCount, PduEvent)>

Returns the earliest accepted PDU and its room-local stream count.

The forward room stream provides the first available item after applying ordinary presentation transformations.

Source§

impl Service

Source

async fn first_item_after( &self, room_id: &RoomId, from: Option<PduCount>, ) -> Result<(PduCount, PduEvent)>

Returns the first accepted PDU after an exclusive from count.

Without a count the room’s backfilled PDUs come first.

Source§

impl Service

Source

pub async fn latest_item_in_room( &self, sender_user: Option<&UserId>, room_id: &RoomId, ) -> Result<PduEvent>

Returns the latest accepted PDU in a room.

sender_user controls presentation of sender-only transaction metadata; it does not filter events by sender.

Source§

impl Service

Source

pub async fn prev_shortstatehash( &self, room_id: &RoomId, before: PduCount, ) -> Result<ShortStateHash>

Returns the state snapshot at the room event directly before a count.

The before boundary is exclusive and need not identify an existing event or even belong to the room.

Source§

impl Service

Source

pub async fn next_shortstatehash( &self, room_id: &RoomId, after: PduCount, ) -> Result<ShortStateHash>

Returns the state snapshot at the room event directly after a count.

The after boundary is exclusive and need not identify an existing event or even belong to the room.

Source§

impl Service

Source

async fn shortroomid(&self, room_id: &RoomId) -> Result<ShortRoomId>

Resolves a room’s short ID.

An unknown room is reported as not found rather than as a storage error.

Source§

impl Service

Source

pub async fn shortstatehash_after( &self, room_id: &RoomId, count: PduCount, ) -> Result<ShortStateHash>

Returns the snapshot preceding the first room event after a count.

An event at the count is treated as already received, because a client’s sync position is often the count of the newest event it received, and need not belong to this room. Current state stands in when no event follows, and a count before the room’s first recorded snapshot is not found. A remote event’s snapshot precedes it in the event graph rather than in this timeline, so the boundary suits a client’s position, not a point in the room’s own history.

Source§

impl Service

Source

pub async fn get_shortstatehash( &self, room_id: &RoomId, count: PduCount, ) -> Result<ShortStateHash>

Returns the state snapshot recorded at a room timeline count.

The count is resolved through the room’s accepted timeline row and then its event-to-state association.

Source§

impl Service

Source

pub async fn prev_timeline_count(&self, before: &PduId) -> Result<PduCount>

Returns the room timeline count directly before an encoded PDU ID.

The boundary is exclusive and need not identify an existing row. Its room component selects the timeline prefix to scan.

Source§

impl Service

Source

pub async fn next_timeline_count(&self, after: &PduId) -> Result<PduCount>

Returns the room timeline count directly after an encoded PDU ID.

The boundary is exclusive and need not identify an existing row. Its room component selects the timeline prefix to scan.

Source§

impl Service

Source

pub async fn last_timeline_count( &self, sender_user: Option<&UserId>, room_id: &RoomId, upper_bound: Option<PduCount>, ) -> Result<PduCount>

Returns the latest normal timeline count at or below an optional bound.

Backfilled counts are not returned. When no normal event qualifies, the sentinel PduCount::max() is returned instead of a not-found error; sender_user affects presentation only.

Source§

impl Service

Source

pub async fn get_event_id_near_ts( &self, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> Result<(MilliSecondsSinceUnixEpoch, OwnedEventId)>

Returns the indexed event ID nearest a timestamp in one direction.

Forward lookup selects the first event at or after the timestamp; backward lookup selects the first event at or before it. The stored event timestamp is returned with the ID.

Source§

impl Service

Source

pub async fn get_pdu_id_near_ts( &self, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> Result<(MilliSecondsSinceUnixEpoch, PduId)>

Returns the indexed PDU ID nearest a timestamp in one direction.

Forward lookup selects the first event at or after the timestamp; backward lookup selects the first event at or before it. A room with no qualifying event returns NotFound.

Source§

impl Service

Source

pub async fn get_pdu_near_ts( &self, _user_id: Option<&UserId>, room_id: &RoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction, ) -> Result<PdusIterItem>

Returns the accepted PDU nearest a timestamp in one direction.

The result contains the selected room-local count and decoded PDU. The current _user_id parameter has no effect and no presentation or visibility filtering is applied.

Source§

impl Service

Source

async fn count_to_id( &self, room_id: &RoomId, count: PduCount, dir: Direction, ) -> Result<RawPduId>

Source§

impl Service

Source

fn pdu_count_to_id( shortroomid: ShortRoomId, count: PduCount, dir: Direction, ) -> RawPduId

Source§

impl Service

Source

pub async fn get_pdu_from_shorteventid( &self, shorteventid: ShortEventId, ) -> Result<PduEvent>

Returns a decoded PDU resolved from a short event ID.

The short ID is expanded to an event ID before accepted and outlier storage are queried through Service::get_pdu.

Source§

impl Service

Source

pub async fn get_pdu(&self, event_id: &EventId) -> Result<PduEvent>

Returns a decoded PDU from accepted or outlier storage.

Both lookups are polled concurrently, so if duplicate rows exist the first successful lookup determines the returned value.

Source§

impl Service

Source

pub async fn get_outlier_pdu(&self, event_id: &EventId) -> Result<PduEvent>

Returns a decoded PDU from outlier storage.

Accepted timeline storage is not consulted, and storage or decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_non_outlier_pdu(&self, event_id: &EventId) -> Result<PduEvent>

Returns a PDU from the accepted timeline.

Looks up the accepted record only, without consulting outliers. Storage and decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_pdu_at( &self, room_id: &RoomId, count: PduCount, ) -> Result<PduEvent>

Returns the accepted PDU at a room’s timeline count.

A count holding no accepted event in the room is not found.

Source§

impl Service

Source

pub async fn get_pdu_from_id(&self, pdu_id: &RawPduId) -> Result<PduEvent>

Returns a decoded PDU by its accepted timeline ID.

The accepted row is read directly without consulting the event-ID mapping or outlier storage.

Source§

impl Service

Source

pub async fn get_pdu_json( &self, event_id: &EventId, ) -> Result<CanonicalJsonObject>

Returns canonical PDU JSON from accepted or outlier storage.

Both lookups are polled concurrently, so if duplicate rows exist the first successful lookup determines the returned value.

Source§

impl Service

Source

pub async fn get_outlier_pdu_json( &self, event_id: &EventId, ) -> Result<CanonicalJsonObject>

Returns canonical PDU JSON from outlier storage.

Accepted timeline storage is not consulted, and storage or decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_non_outlier_pdu_json( &self, event_id: &EventId, ) -> Result<CanonicalJsonObject>

Returns the JSON of a PDU from the accepted timeline.

Looks up the accepted record only, without consulting outliers. Storage and decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_pdu_json_from_id( &self, pdu_id: &RawPduId, ) -> Result<CanonicalJsonObject>

Returns canonical PDU JSON by its accepted timeline ID.

The accepted row is read directly without consulting the event-ID mapping or outlier storage.

Source§

impl Service

Source

pub async fn get<T>(&self, event_id: &EventId) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes an event from accepted or outlier storage into T.

Both lookups are polled concurrently, so if duplicate rows exist the first successful lookup determines the returned value. If both fail, a storage or decoding error takes precedence over a missing record.

Source§

impl Service

Source

pub async fn get_outlier<T>(&self, event_id: &EventId) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes an event from outlier storage into T.

Accepted timeline storage is not consulted, and storage or decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_non_outlier<T>(&self, event_id: &EventId) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes a PDU from the accepted timeline into T.

Resolves the event ID through eventid_pduid and reads pduid_pdu, without consulting outliers. Storage and decoding errors propagate to the caller.

Source§

impl Service

Source

pub async fn get_from_id<T>(&self, pdu_id: &RawPduId) -> Result<T>
where T: for<'de> Deserialize<'de>,

Deserializes an accepted timeline row into T by PDU ID.

The row is read directly without consulting the event-ID mapping or outlier storage.

Source§

impl Service

Source

pub async fn pdu_exists<'a>(&'a self, event_id: &'a EventId) -> bool

Reports whether an event exists in accepted or outlier storage.

The two existence checks run concurrently, and any lookup errors are treated as absence.

Source§

impl Service

Source

pub async fn non_outlier_pdus_exist<'a, I>(&self, event_ids: I) -> bool
where I: Iterator<Item = &'a EventId> + Send,

Reports whether every event has an accepted timeline row.

The probe stops at the first event without one, and an empty input reports true; a lookup error counts as absence. The rows are read one at a time, so callers pass a small set such as one event’s references, never a bulk population.

Source§

impl Service

Source

pub fn watch_event<'a>( &'a self, event_id: &EventId, ) -> impl Future<Output = ()> + Send + 'a

Returns a future that resolves on the next event-to-PDU mapping mutation.

Registration against the event-to-PDU mapping is eager, so the watcher is installed before the returned future is first awaited. Accepted insertion is the normal wakeup, but any mutation under the event-ID prefix can resolve the future.

Source§

impl Service

Source

pub async fn non_outlier_pdu_exists(&self, event_id: &EventId) -> Result

Checks whether an event has an accepted timeline row.

The event-to-PDU mapping is resolved first and the target row is then tested without fetching or decoding the PDU.

Source§

impl Service

Source

pub async fn outlier_pdu_exists(&self, event_id: &EventId) -> Result

Checks whether an event has an outlier row.

Accepted timeline storage is not consulted and the PDU is not fetched or decoded.

Source§

impl Service

Source

pub async fn get_pdu_count(&self, event_id: &EventId) -> Result<PduCount>

Returns the room-local timeline count assigned to an accepted event.

The event ID is resolved through the accepted event-to-PDU mapping.

Source§

impl Service

Source

pub async fn get_shorteventid_from_pdu_id( &self, pdu_id: &PduId, ) -> Result<ShortEventId>

Returns the short event ID represented by an accepted PDU ID.

The accepted row supplies the full event ID, which is then resolved through the short-ID service.

Source§

impl Service

Source

pub async fn get_event_id_from_pdu_id( &self, pdu_id: &PduId, ) -> Result<OwnedEventId>

Returns the event ID stored at an accepted PDU ID.

The accepted row is decoded as a PDU to recover its event ID.

Source§

impl Service

Source

pub async fn get_pdu_id_from_shorteventid( &self, shorteventid: ShortEventId, ) -> Result<RawPduId>

Returns the accepted PDU ID associated with a short event ID.

The short ID is first expanded to its full event ID before the timeline mapping is read.

Source§

impl Service

Source

pub async fn get_pdu_id(&self, event_id: &EventId) -> Result<RawPduId>

Returns the accepted timeline ID associated with an event.

Outlier storage is not consulted because outliers have no room timeline position.

Trait Implementations§

Source§

impl FetchEvent for &Service

Source§

async fn get<T>(self, event_id: &EventId) -> Result<T>
where T: for<'de> Deserialize<'de> + Send,

Decodes an event into the requested representation. Read more
Source§

async fn exists(self, event_id: &EventId) -> Result<bool>

Checks whether an event exists without requiring a full decode. Read more
Source§

impl Service for Service

Source§

fn build(args: &Args<'_>) -> Result<Arc<Self>>

Implement the construction of the service instance. Services are generally singletons so expect this to only be called once for a service type. Note that it may be called again after a server reload, but the prior instance will have been dropped first. Failure will shutdown the server with an error.
Source§

fn memory_usage<'life0, 'life1, 'async_trait>( &'life0 self, out: &'life1 mut (dyn Write + Send), ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Memory usage report in a markdown string.
Source§

fn name(&self) -> &str

Return the name of the service. i.e. crate::service::make_name(std::module_path!())
Source§

fn worker<'async_trait>( self: Arc<Self>, ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait,

Implement the service’s worker loop. The service manager spawns a task and calls this function after all services have been built.
Source§

fn interrupt<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Interrupt the service. This is sent to initiate a graceful shutdown. The service worker should return from its work loop.
Source§

fn clear_cache<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear any caches or similar runtime state.
Source§

fn unconstrained(&self) -> bool

Return true if the service worker opts out of the tokio cooperative budgeting. This can reduce tail latency at the risk of event loop starvation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> DropFlavorWrapper<T> for T

§

type Flavor = MayDrop

The DropFlavor that [wrap]s T into Self
Source§

impl<T> ExpectInto for T

Source§

fn expect_into<Dst>(self) -> Dst
where Dst: TryFrom<Self>, Self: Sized,

Converts the value into Dst and returns the successful result. Read more
Source§

impl<T> Expected for T

Source§

fn expected_add(self, rhs: Self) -> Self
where Self: Sized + CheckedAdd,

Adds rhs with an expectation that the operation is valid. Read more
Source§

fn expected_sub(self, rhs: Self) -> Self
where Self: Sized + CheckedSub,

Subtracts rhs with an expectation that the operation is valid. Read more
Source§

fn expected_mul(self, rhs: Self) -> Self
where Self: Sized + CheckedMul,

Multiplies by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_div(self, rhs: Self) -> Self
where Self: Sized + CheckedDiv,

Divides by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_rem(self, rhs: Self) -> Self
where Self: Sized + CheckedRem,

Computes the remainder with an expectation that the operation is valid. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

§

impl<T> Paint for T
where T: ?Sized,

§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling [Attribute] value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi [Quirk] value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the [Condition] value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn add_extension<T>(self, value: T) -> AddExtension<Self, T>
where Self: Sized,

Add some shareable value to request extensions. Read more
§

fn compression(self) -> Compression<Self>
where Self: Sized,

Compresses response bodies. Read more
§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
§

fn sensitive_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>
where Self: Sized,

Mark headers as sensitive on both requests and responses. Read more
§

fn sensitive_request_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<Self>
where Self: Sized,

Mark headers as sensitive on requests. Read more
§

fn sensitive_response_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveResponseHeaders<Self>
where Self: Sized,

Mark headers as sensitive on responses. Read more
§

fn override_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request. Read more
§

fn append_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Append a header into the request. Read more
§

fn insert_request_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request, if the header is not already present. Read more
§

fn override_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response. Read more
§

fn append_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Append a header into the response. Read more
§

fn insert_response_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response, if the header is not already present. Read more
§

fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>
where Self: Sized,

Catch panics and convert them into 500 Internal Server responses. Read more
Source§

impl<T> Tried for T

Source§

fn try_add(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedAdd,

Adds rhs with checked arithmetic. Read more
Source§

fn try_sub(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedSub,

Subtracts rhs with checked arithmetic. Read more
Source§

fn try_mul(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedMul,

Multiplies by rhs with checked arithmetic. Read more
Source§

fn try_div(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedDiv,

Divides by rhs with checked arithmetic. Read more
Source§

fn try_rem(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedRem,

Computes the remainder by rhs with checked arithmetic. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more