pub struct SchemaRegistryClient { /* private fields */ }Expand description
Async client for the Confluent Schema Registry REST API.
Provides schema lookup by ID and subject, caching with LRU eviction and TTL, compatibility checking, and Avro-to-Arrow schema conversion.
Implementations§
Source§impl SchemaRegistryClient
impl SchemaRegistryClient
Sourcepub fn new(base_url: impl Into<String>, auth: Option<SrAuth>) -> Self
pub fn new(base_url: impl Into<String>, auth: Option<SrAuth>) -> Self
Creates a new Schema Registry client with default cache config.
Sourcepub fn with_tls(
base_url: impl Into<String>,
auth: Option<SrAuth>,
ca_cert_path: &str,
) -> Result<Self, ConnectorError>
pub fn with_tls( base_url: impl Into<String>, auth: Option<SrAuth>, ca_cert_path: &str, ) -> Result<Self, ConnectorError>
Creates a TLS client (CA cert only). Delegates to Self::with_tls_mtls.
§Errors
Returns ConnectorError::ConfigurationError if the CA cert cannot be read.
Sourcepub fn with_tls_mtls(
base_url: impl Into<String>,
auth: Option<SrAuth>,
ca_cert_path: &str,
client_cert_path: Option<&str>,
client_key_path: Option<&str>,
) -> Result<Self, ConnectorError>
pub fn with_tls_mtls( base_url: impl Into<String>, auth: Option<SrAuth>, ca_cert_path: &str, client_cert_path: Option<&str>, client_key_path: Option<&str>, ) -> Result<Self, ConnectorError>
Creates a client with full TLS/mTLS support.
§Errors
Returns ConnectorError::ConfigurationError if any cert/key file
cannot be read or parsed.
Sourcepub fn with_cache_config(
base_url: impl Into<String>,
auth: Option<SrAuth>,
cache_config: SchemaRegistryCacheConfig,
) -> Self
pub fn with_cache_config( base_url: impl Into<String>, auth: Option<SrAuth>, cache_config: SchemaRegistryCacheConfig, ) -> Self
Creates a new Schema Registry client with custom cache config.
Sourcepub fn cache_config(&self) -> &SchemaRegistryCacheConfig
pub fn cache_config(&self) -> &SchemaRegistryCacheConfig
Returns the cache configuration.
Sourcepub async fn get_schema_by_id(
&self,
id: i32,
) -> Result<CachedSchema, ConnectorError>
pub async fn get_schema_by_id( &self, id: i32, ) -> Result<CachedSchema, ConnectorError>
Fetches a schema by its global ID.
Results are cached for subsequent lookups.
§Errors
Returns ConnectorError if the HTTP request fails or the schema
cannot be parsed.
Sourcepub async fn get_latest_schema(
&self,
subject: &str,
) -> Result<CachedSchema, ConnectorError>
pub async fn get_latest_schema( &self, subject: &str, ) -> Result<CachedSchema, ConnectorError>
Fetches the latest schema version for a subject.
§Errors
Returns ConnectorError if the HTTP request fails.
Sourcepub async fn get_schema_version(
&self,
subject: &str,
version: i32,
) -> Result<CachedSchema, ConnectorError>
pub async fn get_schema_version( &self, subject: &str, version: i32, ) -> Result<CachedSchema, ConnectorError>
Fetches a specific schema version for a subject.
§Errors
Returns ConnectorError if the HTTP request fails.
Sourcepub async fn check_compatibility(
&self,
subject: &str,
schema_str: &str,
) -> Result<CompatibilityResult, ConnectorError>
pub async fn check_compatibility( &self, subject: &str, schema_str: &str, ) -> Result<CompatibilityResult, ConnectorError>
Checks compatibility of a schema against the latest version.
§Errors
Returns ConnectorError if the HTTP request fails.
Sourcepub async fn get_compatibility_level(
&self,
subject: &str,
) -> Result<CompatibilityLevel, ConnectorError>
pub async fn get_compatibility_level( &self, subject: &str, ) -> Result<CompatibilityLevel, ConnectorError>
Gets the compatibility level for a subject.
§Errors
Returns ConnectorError if the HTTP request fails.
Sourcepub async fn set_compatibility_level(
&self,
subject: &str,
level: CompatibilityLevel,
) -> Result<(), ConnectorError>
pub async fn set_compatibility_level( &self, subject: &str, level: CompatibilityLevel, ) -> Result<(), ConnectorError>
Sets the compatibility level for a subject.
§Errors
Returns ConnectorError if the HTTP request fails.
Sourcepub async fn resolve_confluent_id(
&self,
id: i32,
) -> Result<CachedSchema, ConnectorError>
pub async fn resolve_confluent_id( &self, id: i32, ) -> Result<CachedSchema, ConnectorError>
Resolves a Confluent schema ID, returning from cache if available.
This is the hot-path method called during Avro deserialization to look up schemas by the 4-byte ID in the Confluent wire format.
§Errors
Returns ConnectorError if the schema cannot be fetched.
Sourcepub async fn register_schema(
&self,
subject: &str,
schema_str: &str,
schema_type: SchemaType,
) -> Result<i32, ConnectorError>
pub async fn register_schema( &self, subject: &str, schema_str: &str, schema_type: SchemaType, ) -> Result<i32, ConnectorError>
Registers a schema with the Schema Registry under the given subject.
Returns the schema ID assigned by the registry. Caches the result so subsequent calls with the same subject return immediately.
§Errors
Returns ConnectorError if the HTTP request fails or the response
is malformed.
Sourcepub async fn validate_and_register_schema(
&self,
subject: &str,
schema_str: &str,
schema_type: SchemaType,
) -> Result<i32, ConnectorError>
pub async fn validate_and_register_schema( &self, subject: &str, schema_str: &str, schema_type: SchemaType, ) -> Result<i32, ConnectorError>
Validates compatibility and registers a schema in one step.
If the subject already has schemas registered, checks compatibility
first. Returns SerdeError::SchemaIncompatible if the new schema
is not compatible with the existing versions.
§Errors
Returns ConnectorError::Serde(SchemaIncompatible) if incompatible,
or ConnectorError for HTTP/network errors.
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Returns the number of cached schemas.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaRegistryClient
impl !RefUnwindSafe for SchemaRegistryClient
impl Send for SchemaRegistryClient
impl Sync for SchemaRegistryClient
impl Unpin for SchemaRegistryClient
impl UnsafeUnpin for SchemaRegistryClient
impl !UnwindSafe for SchemaRegistryClient
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> AsAny for T
impl<T> AsAny for T
§fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
dyn Any reference to the object: Read more§fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
Arc<dyn Any> reference to the object: Read more§fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn Any>: Read more§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
std::any::type_name, since Any does not provide it and
Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).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<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.