pub struct Schema { /* private fields */ }Expand description
Resolves a Transcoder for a gRPC method path according to a SchemaSource.
Cheap to clone; the reflection snapshot is shared.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn from_transcoder(transcoder: Option<Arc<Transcoder>>) -> Self
pub fn from_transcoder(transcoder: Option<Arc<Transcoder>>) -> Self
Build a schema from an already-constructed transcoder — the in-process case, where
the descriptors live in memory and there is no upstream to reflect against. None
means no +json transcoder is configured.
Sourcepub fn build(
source: SchemaSource,
channel: Channel,
ttl: Duration,
) -> Result<Self, TranscodeError>
pub fn build( source: SchemaSource, channel: Channel, ttl: Duration, ) -> Result<Self, TranscodeError>
Build a resolver. The Bundled set is parsed eagerly so a bad descriptor set
fails at startup; channel is the upstream connection reused for reflection, and
ttl is the reflection refresh interval. Call Schema::start afterwards to
kick off the reflection loader.
Sourcepub fn start(&self)
pub fn start(&self)
Start the background reflection loader (eager initial load + TTL refresh). A no-op unless the source involves reflection. Must be called from within a Tokio runtime.
Sourcepub async fn reload(&self) -> Result<(), Status>
pub async fn reload(&self) -> Result<(), Status>
Force an immediate reflection reload, returning its result. The management hook
behind ProxyConfig::admin_reload_path.
Sourcepub async fn transcoder_any(&self) -> Result<Arc<Transcoder>, Status>
pub async fn transcoder_any(&self) -> Result<Arc<Transcoder>, Status>
The transcoder for this source, without validating any specific method — for REST annotation matching, where the target method isn’t known until the URL is matched against the router.
Sourcepub async fn transcoder(
&self,
method_path: &str,
) -> Result<Arc<Transcoder>, Status>
pub async fn transcoder( &self, method_path: &str, ) -> Result<Arc<Transcoder>, Status>
Resolve the transcoder for method_path (/pkg.Service/Method). An unknown
method yields Unimplemented (uniformly across sources), distinct from a
transcode failure.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Schema
impl !UnwindSafe for Schema
impl Freeze for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
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<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request