pub struct Service {
db: Data,
creating: Creating,
services: Arc<OnceServices>,
}Expand description
Allocates and resolves compact identifiers used by room storage.
Per-identity locks serialize first allocation, and database transactions keep new forward and reverse mappings consistent where both are stored.
Fields§
§db: Data§creating: Creating§services: Arc<OnceServices>Implementations§
Source§impl Service
impl Service
Sourcepub async fn get_or_create_shorteventid(
&self,
event_id: &EventId,
) -> ShortEventId
pub async fn get_or_create_shorteventid( &self, event_id: &EventId, ) -> ShortEventId
Resolves an event ID to its compact identifier, allocating after an unsuccessful lookup.
New allocations publish the forward and reverse mappings in one transaction. Concurrent callers for the same event converge on one identifier.
§Panics
Panics when identifier dispatch or the paired mapping transaction fails.
Source§impl Service
impl Service
Sourcepub fn multi_get_or_create_shorteventid<'a, I>(
&'a self,
event_ids: I,
) -> impl Stream<Item = ShortEventId> + Send + '_
pub fn multi_get_or_create_shorteventid<'a, I>( &'a self, event_ids: I, ) -> impl Stream<Item = ShortEventId> + Send + '_
Resolves each event ID to its short ID, allocating after unsuccessful lookups.
Allocation runs ahead of consumer demand, so a caller that stops early still allocates for the events already buffered. Today’s callers drain the stream in full.
§Panics
Panics when an existing mapping is malformed, identifier dispatch fails, or a paired mapping transaction fails.
Source§impl Service
impl Service
async fn create_shorteventid(&self, event_id: &EventId) -> ShortEventId
Source§impl Service
impl Service
Sourcepub async fn get_shorteventid(&self, event_id: &EventId) -> Result<ShortEventId>
pub async fn get_shorteventid(&self, event_id: &EventId) -> Result<ShortEventId>
Resolves an event ID to its existing compact identifier.
Missing or malformed mappings are returned as database errors.
Source§impl Service
impl Service
Sourcepub async fn get_or_create_shortstatekey(
&self,
event_type: &StateEventType,
state_key: &str,
) -> ShortStateKey
pub async fn get_or_create_shortstatekey( &self, event_type: &StateEventType, state_key: &str, ) -> ShortStateKey
Resolves a state event type and key, allocating an identifier after an unsuccessful lookup.
New allocations publish the forward and reverse mappings in one transaction. Concurrent callers for the same pair converge on one identifier.
§Panics
Panics when identifier dispatch or the paired mapping transaction fails.
Source§impl Service
impl Service
async fn create_shortstatekey( &self, event_type: &StateEventType, state_key: &str, ) -> ShortStateKey
Source§impl Service
impl Service
Sourcepub async fn get_shortstatekey(
&self,
event_type: &StateEventType,
state_key: &str,
) -> Result<ShortStateKey>
pub async fn get_shortstatekey( &self, event_type: &StateEventType, state_key: &str, ) -> Result<ShortStateKey>
Resolves a state event type and key to its existing compact identifier.
The event type and state key together form the forward lookup key. Missing or malformed mappings are returned as database errors.
Source§impl Service
impl Service
Sourcepub async fn get_eventid_from_short<Id>(
&self,
shorteventid: ShortEventId,
) -> Result<Id>
pub async fn get_eventid_from_short<Id>( &self, shorteventid: ShortEventId, ) -> Result<Id>
Resolves a compact event identifier through the reverse mapping.
The caller selects a deserializable event-ID representation whose owned form can be borrowed as
[EventId]. Missing or malformed rows are reported with the compact identifier.
Source§impl Service
impl Service
Sourcepub fn multi_get_eventid_from_short<'a, Id, S>(
&'a self,
shorteventid: S,
) -> impl Stream<Item = Result<Id>> + Send + 'awhere
S: Stream<Item = ShortEventId> + Send + 'a,
Id: for<'de> Deserialize<'de> + Send + Sized + ToOwned + 'a,
<Id as ToOwned>::Owned: Borrow<EventId>,
pub fn multi_get_eventid_from_short<'a, Id, S>(
&'a self,
shorteventid: S,
) -> impl Stream<Item = Result<Id>> + Send + 'awhere
S: Stream<Item = ShortEventId> + Send + 'a,
Id: for<'de> Deserialize<'de> + Send + Sized + ToOwned + 'a,
<Id as ToOwned>::Owned: Borrow<EventId>,
Resolves a stream of compact event identifiers through the reverse mapping.
Input order is preserved. Each output carries its own lookup or deserialization result.
Source§impl Service
impl Service
Sourcepub async fn get_statekey_from_short(
&self,
shortstatekey: ShortStateKey,
) -> Result<(StateEventType, StateKey)>
pub async fn get_statekey_from_short( &self, shortstatekey: ShortStateKey, ) -> Result<(StateEventType, StateKey)>
Resolves a compact state-key identifier to its event type and state key.
Missing or malformed reverse mappings are returned as database errors that identify the compact value.
Source§impl Service
impl Service
Sourcepub fn multi_get_statekey_from_short<'a, S>(
&'a self,
shortstatekey: S,
) -> impl Stream<Item = Result<(StateEventType, StateKey)>> + Send + 'awhere
S: Stream<Item = ShortStateKey> + Send + 'a,
pub fn multi_get_statekey_from_short<'a, S>(
&'a self,
shortstatekey: S,
) -> impl Stream<Item = Result<(StateEventType, StateKey)>> + Send + 'awhere
S: Stream<Item = ShortStateKey> + Send + 'a,
Resolves a stream of compact state-key identifiers through the reverse mapping.
Input order is preserved. Each output carries its own lookup or deserialization result.
Source§impl Service
impl Service
Sourcepub async fn get_or_create_shortstatehash<F>(
&self,
state_hash: &Digest,
write_statediff: F,
) -> Result<(ShortStateHash, bool)>
pub async fn get_or_create_shortstatehash<F>( &self, state_hash: &Digest, write_statediff: F, ) -> Result<(ShortStateHash, bool)>
Resolves a state hash, allocating a compact identifier after an unsuccessful lookup.
The returned boolean is true when the mapping already existed, in which case the callback is
skipped. For a new identifier, write_statediff stages its associated state diff in the same
transaction as the mapping.
§Errors
Returns an error when write_statediff rejects the new state diff. Neither row is committed.
§Panics
Panics when identifier dispatch or the mapping and state-diff transaction fails.
Source§impl Service
impl Service
async fn create_shortstatehash<F>( &self, state_hash: &Digest, write_statediff: F, ) -> Result<(ShortStateHash, bool)>
Source§impl Service
impl Service
Sourcepub async fn get_shortstatehash(
&self,
state_hash: &Digest,
) -> Result<ShortStateHash>
pub async fn get_shortstatehash( &self, state_hash: &Digest, ) -> Result<ShortStateHash>
Resolves a state hash to its existing compact identifier.
Missing or malformed mappings are returned as database errors.
Source§impl Service
impl Service
Sourcepub async fn get_shortroomid(&self, room_id: &RoomId) -> Result<ShortRoomId>
pub async fn get_shortroomid(&self, room_id: &RoomId) -> Result<ShortRoomId>
Resolves a room ID to its existing compact identifier.
Missing or malformed mappings are returned as database errors.
Source§impl Service
impl Service
Sourcepub async fn get_roomid_from_short(
&self,
shortroomid_: ShortRoomId,
) -> Result<OwnedRoomId>
pub async fn get_roomid_from_short( &self, shortroomid_: ShortRoomId, ) -> Result<OwnedRoomId>
Resolves a compact room identifier by scanning the forward mapping.
Room identifiers have no dedicated reverse map, so the first matching value is returned. Unreadable rows are skipped during the scan.
Source§impl Service
impl Service
Sourcepub fn iter_shortroomids(
&self,
) -> impl Stream<Item = (&RoomId, ShortRoomId)> + Send + '_
pub fn iter_shortroomids( &self, ) -> impl Stream<Item = (&RoomId, ShortRoomId)> + Send + '_
Streams every room ID with its compact identifier.
This scan is the only way back from a compact room identifier, so resolve several in one pass. Each borrowed ID is valid only until the next poll, and unreadable rows are skipped.
Source§impl Service
impl Service
Sourcepub async fn get_or_create_shortroomid(&self, room_id: &RoomId) -> ShortRoomId
pub async fn get_or_create_shortroomid(&self, room_id: &RoomId) -> ShortRoomId
Resolves a room ID to its compact identifier, allocating after an unsuccessful lookup.
Room mappings are stored only in the forward direction. Concurrent callers for the same room converge on one identifier.
§Panics
Panics when identifier dispatch or storing the forward mapping fails.
Source§impl Service
impl Service
async fn create_shortroomid(&self, room_id: &RoomId) -> ShortRoomId
Trait Implementations§
Source§impl Service for Service
impl Service for Service
Source§fn build(args: &Args<'_>) -> Result<Arc<Self>>
fn build(args: &Args<'_>) -> Result<Arc<Self>>
Source§fn name(&self) -> &str
fn name(&self) -> &str
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,
fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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,
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,
Source§fn unconstrained(&self) -> bool
fn unconstrained(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for Service
impl !UnwindSafe for Service
impl Freeze for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnsafeUnpin for Service
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> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
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);§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
rhs with checked arithmetic. Read more