pub trait SchemaSource: Send + Sync {
// Required method
fn load(&self) -> Result<TypeSchema, PipelineError>;
}Expand description
Source of a TypeDB schema for the query pipeline.
Implement this trait to load a schema from any source: a file on disk, an in-memory string, a remote URL, or even directly from TypeDB.
§Example
ⓘ
use type_bridge_server::{SchemaSource, PipelineError};
use type_bridge_core_lib::schema::TypeSchema;
struct RemoteSchemaSource { url: String }
impl SchemaSource for RemoteSchemaSource {
fn load(&self) -> Result<TypeSchema, PipelineError> {
let content = fetch_schema(&self.url)?;
TypeSchema::from_typeql(&content)
.map_err(|e| PipelineError::Schema(e.to_string()))
}
}Required Methods§
Sourcefn load(&self) -> Result<TypeSchema, PipelineError>
fn load(&self) -> Result<TypeSchema, PipelineError>
Load and parse the schema, returning a TypeSchema.