#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompatibilityMode {
None,
Backward,
Forward,
Full,
}
impl CompatibilityMode {
pub fn as_str(&self) -> &'static str {
match self {
CompatibilityMode::None => "none",
CompatibilityMode::Backward => "backward",
CompatibilityMode::Forward => "forward",
CompatibilityMode::Full => "full",
}
}
}
impl Default for CompatibilityMode {
fn default() -> Self {
CompatibilityMode::Backward
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SchemaType {
Bytes,
String,
Number,
Avro,
JsonSchema,
Protobuf,
}
impl SchemaType {
pub fn as_str(&self) -> &'static str {
match self {
SchemaType::Bytes => "bytes",
SchemaType::String => "string",
SchemaType::Number => "number",
SchemaType::Avro => "avro",
SchemaType::JsonSchema => "json_schema",
SchemaType::Protobuf => "protobuf",
}
}
}
use danube_core::proto::danube_schema::GetSchemaResponse as ProtoGetSchemaResponse;
#[derive(Debug, Clone)]
pub struct SchemaInfo {
pub schema_id: u64,
pub subject: String,
pub version: u32,
pub schema_type: String,
pub schema_definition: Vec<u8>,
pub fingerprint: String,
}
impl SchemaInfo {
pub fn schema_definition_as_string(&self) -> Option<String> {
String::from_utf8(self.schema_definition.clone()).ok()
}
}
impl From<ProtoGetSchemaResponse> for SchemaInfo {
fn from(proto: ProtoGetSchemaResponse) -> Self {
SchemaInfo {
schema_id: proto.schema_id,
subject: proto.subject,
version: proto.version,
schema_type: proto.schema_type,
schema_definition: proto.schema_definition,
fingerprint: proto.fingerprint,
}
}
}