Skip to main content

SchemaConfig

Struct SchemaConfig 

Source
pub struct SchemaConfig {
    pub table: String,
    pub title: Option<String>,
    pub description: Option<String>,
    pub fields: Vec<FieldDef>,
    pub dump: Option<DumpConfig>,
}
Expand description

The parsed contents of a schema.yaml file.

This struct is the runtime representation of the schema and acts as the single source of truth for all validation decisions. It is created once at daemon startup via load_from_path and passed to every CRUD operation.

§Fields

  • table: the SQLite table name (also used as a human-readable label).
  • title: optional human-readable title for the table (short summary).
  • description: optional long-form description for the table.
  • fields: ordered list of field definitions.
  • dump: optional write-only file-materialization configuration.

Fields§

§table: String

The logical table name declared in schema.yaml.

§title: Option<String>

Optional human-readable title for the table (short summary, plain string).

§description: Option<String>

Optional long-form description for the table. Plain string; CommonMark MAY be used by render tools (server stores it verbatim).

§fields: Vec<FieldDef>

All field definitions, in declaration order.

§dump: Option<DumpConfig>

Optional dump / file-materialization configuration.

When absent from schema.yaml, the field deserializes to None and the dump feature is disabled entirely (backward-compatible default).

Implementations§

Source§

impl SchemaConfig

Source

pub async fn write_to_path(&self, path: &Path) -> Result<(), MiniAppError>

Writes this schema to a YAML file using an atomic tmp+rename strategy.

The write is performed inside tokio::task::spawn_blocking to avoid blocking the async executor (K-110). The rename is performed with std::fs::rename, which is atomic on the same filesystem on Linux/macOS (POSIX rename(2) guarantee).

§Algorithm
  1. Serialise self to a YAML string via serde_yaml_bw::to_string.
  2. Write to <path>.tmp (same directory, so same filesystem).
  3. Atomically rename <path>.tmp to <path>.
§Arguments
  • path: destination path for schema.yaml (the final file, not .tmp).
§Returns

Ok(()) on success.

§Errors
Source

pub fn validate(&self, value: &Value) -> Result<(), MiniAppError>

Validates a JSON object against this schema.

Rules (applied in order, iterating over [self.fields]):

  1. If field.required is true and the key is absent from value (or its value is null), return MiniAppError::Validation with reason = "required field missing".
  2. If the key is present and non-null but its JSON type does not match field.ty, return MiniAppError::Validation with a descriptive reason.
  3. Unknown keys (present in value but not in self.fields) are silently accepted — Agent-First extensibility.
§Arguments
  • value: the JSON object to validate. Must be a serde_json::Value::Object; if it is not, a Validation error is returned immediately.
§Errors

Returns MiniAppError::Validation on the first validation failure encountered.

Trait Implementations§

Source§

impl Clone for SchemaConfig

Source§

fn clone(&self) -> SchemaConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SchemaConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SchemaConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more