ModelSaver

Struct ModelSaver 

Source
pub struct ModelSaver<B>
where B: StorageBackend,
{ /* private fields */ }
Expand description

Model saver that uses a storage backend

Implementations§

Source§

impl<B> ModelSaver<B>
where B: StorageBackend,

Source

pub fn new(storage: B) -> ModelSaver<B>

Create a new model saver with the given storage backend

Source

pub async fn save_table( &self, workspace_path: &str, table: &TableData, ) -> Result<(), StorageError>

Save a table to storage

Saves the table as a YAML file in the workspace’s tables/ directory. The filename will be based on the table name if yaml_file_path is not provided.

Source

pub async fn save_relationships( &self, workspace_path: &str, relationships: &[RelationshipData], ) -> Result<(), StorageError>

Save relationships to storage

Saves relationships to relationships.yaml in the workspace directory. Note: Relationships are now stored within domain.yaml files, but this method is kept for backward compatibility.

Source

pub async fn save_domain( &self, workspace_path: &str, domain: &Domain, tables: &HashMap<Uuid, Table>, odps_products: &HashMap<Uuid, ODPSDataProduct>, cads_assets: &HashMap<Uuid, CADSAsset>, ) -> Result<(), StorageError>

Save a domain to storage

Saves the domain as domain.yaml in a domain directory named after the domain. Also saves all associated ODCS tables, ODPS products, and CADS assets within the domain directory.

Source

pub async fn save_odps_product( &self, workspace_path: &str, domain_name: &str, product: &ODPSDataProduct, ) -> Result<(), StorageError>

Save an ODPS product to a domain directory

Saves the product as {product_name}.odps.yaml in the specified domain directory.

Source

pub async fn save_cads_asset( &self, workspace_path: &str, domain_name: &str, asset: &CADSAsset, ) -> Result<(), StorageError>

Save a CADS asset to a domain directory

Saves the asset as {asset_name}.cads.yaml in the specified domain directory.

Source

pub async fn save_decision( &self, workspace_path: &str, workspace_name: &str, decision: &Decision, ) -> Result<String, StorageError>

Save a decision to storage

Saves the decision as a YAML file using the naming convention: {workspace}_{domain}_adr-{number}.madr.yaml (with domain) or {workspace}_adr-{number}.madr.yaml (without domain)

§Arguments
  • workspace_path - Path to the workspace directory
  • workspace_name - Name of the workspace for filename generation
  • decision - The decision to save
Source

pub async fn save_decision_index( &self, workspace_path: &str, index: &DecisionIndex, ) -> Result<(), StorageError>

Save the decision index to decisions.yaml

§Arguments
  • workspace_path - Path to the workspace directory
  • index - The decision index to save
Source

pub async fn save_knowledge( &self, workspace_path: &str, workspace_name: &str, article: &KnowledgeArticle, ) -> Result<String, StorageError>

Save a knowledge article to storage

Saves the article as a YAML file using the naming convention: {workspace}_{domain}_kb-{number}.kb.yaml (with domain) or {workspace}_kb-{number}.kb.yaml (without domain)

§Arguments
  • workspace_path - Path to the workspace directory
  • workspace_name - Name of the workspace for filename generation
  • article - The knowledge article to save
Source

pub async fn save_knowledge_index( &self, workspace_path: &str, index: &KnowledgeIndex, ) -> Result<(), StorageError>

Save the knowledge index to knowledge.yaml

§Arguments
  • workspace_path - Path to the workspace directory
  • index - The knowledge index to save
Source

pub async fn export_decision_markdown( &self, workspace_path: &str, decision: &Decision, ) -> Result<String, StorageError>

Export a decision to Markdown

Saves the decision as a Markdown file in the decisions/ subdirectory using the filename format: ADR-NNNN-slug.md

§Arguments
  • workspace_path - Path to the workspace directory
  • decision - The decision to export
Source

pub async fn export_knowledge_markdown( &self, workspace_path: &str, article: &KnowledgeArticle, ) -> Result<String, StorageError>

Export a knowledge article to Markdown

Saves the article as a Markdown file in the knowledge/ subdirectory using the filename format: KB-NNNN-slug.md

§Arguments
  • workspace_path - Path to the workspace directory
  • article - The knowledge article to export
Source

pub async fn export_all_decisions_markdown( &self, workspace_path: &str, decisions: &[Decision], ) -> Result<usize, StorageError>

Export all decisions to Markdown

Exports all provided decisions to the decisions/ subdirectory

§Arguments
  • workspace_path - Path to the workspace directory
  • decisions - The decisions to export
§Returns

The number of decisions exported

Source

pub async fn export_all_knowledge_markdown( &self, workspace_path: &str, articles: &[KnowledgeArticle], ) -> Result<usize, StorageError>

Export all knowledge articles to Markdown

Exports all provided articles to the knowledge/ subdirectory

§Arguments
  • workspace_path - Path to the workspace directory
  • articles - The knowledge articles to export
§Returns

The number of articles exported

Auto Trait Implementations§

§

impl<B> Freeze for ModelSaver<B>
where B: Freeze,

§

impl<B> RefUnwindSafe for ModelSaver<B>
where B: RefUnwindSafe,

§

impl<B> Send for ModelSaver<B>

§

impl<B> Sync for ModelSaver<B>

§

impl<B> Unpin for ModelSaver<B>
where B: Unpin,

§

impl<B> UnwindSafe for ModelSaver<B>
where B: UnwindSafe,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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