pub struct SchemaStore { /* private fields */ }Expand description
Per-producer schema sets, fetched lazily and cached for the process.
Implementations§
Source§impl SchemaStore
impl SchemaStore
pub fn new(base: impl Into<String>, timeout: Duration) -> Self
Sourcepub fn decoders_mut(&mut self) -> &mut DecoderRegistry
pub fn decoders_mut(&mut self) -> &mut DecoderRegistry
The decoder table (register custom kinds through this).
Sourcepub async fn schema_for(
&self,
session: &Session,
producer: &str,
type_name: &str,
) -> Option<TypeSchema>
pub async fn schema_for( &self, session: &Session, producer: &str, type_name: &str, ) -> Option<TypeSchema>
The schema for type_name as served by producer, fetching
@rpc/<producer>/describe on first miss. None = the producer does
not serve describe or does not describe this type — render
structurally (never an error; RFC 08 §7 is a SHOULD for
self-describing encodings).
Sourcepub async fn set_for(
&self,
session: &Session,
producer: &str,
) -> Option<Arc<SchemaSet>>
pub async fn set_for( &self, session: &Session, producer: &str, ) -> Option<Arc<SchemaSet>>
The producer’s whole served set, on the same fetch-and-cache path
as schema_for (issue #51: zenctl schema <producer> dumps the inventory, and asking type-by-type would be a
different question than the one describe answers).
None = the producer does not serve describe — an honest
degradation, never an error.
Sourcepub fn forget(&self, producer: &str)
pub fn forget(&self, producer: &str)
Forget what we learned about one producer, so the next question goes to the bus (issue #101).
The queriers are kept: they are idle routing state, and re-declaring them is exactly the cost #37 removed.
Sourcepub fn forget_all(&self)
pub fn forget_all(&self)
Forget every producer — the “re-ask schemas” action a frontend offers.
Covers the case the backoff cannot: a positive entry never expires, so a producer that changes its served set mid-session is otherwise read with the schemas it had at first contact.
Sourcepub fn known(&self) -> Vec<(String, bool)>
pub fn known(&self) -> Vec<(String, bool)>
Producers currently answered-for, and whether each served a set — what a frontend shows next to its re-ask button.
Sourcepub fn decode(
&self,
schema: &TypeSchema,
encoding: &WireEncoding,
bytes: &[u8],
) -> Result<DecodedPayload, DecodeError>
pub fn decode( &self, schema: &TypeSchema, encoding: &WireEncoding, bytes: &[u8], ) -> Result<DecodedPayload, DecodeError>
Decode bytes under a schema, if one resolves.
Sourcepub fn encode(
&self,
schema: &TypeSchema,
value: &Value,
target: &WireEncoding,
) -> Result<Vec<u8>, DecodeError>
pub fn encode( &self, schema: &TypeSchema, value: &Value, target: &WireEncoding, ) -> Result<Vec<u8>, DecodeError>
The other direction (issue #97): a JSON value framed for the wire. The store owns the decoder table, so the write path resolves its codec exactly where the read path does — one registration, both directions.
Auto Trait Implementations§
impl !Freeze for SchemaStore
impl !RefUnwindSafe for SchemaStore
impl !UnwindSafe for SchemaStore
impl Send for SchemaStore
impl Sync for SchemaStore
impl Unpin for SchemaStore
impl UnsafeUnpin for SchemaStore
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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