ODCSContract

Struct ODCSContract 

Source
pub struct ODCSContract {
Show 24 fields pub api_version: String, pub kind: String, pub id: String, pub version: String, pub name: String, pub status: Option<String>, pub domain: Option<String>, pub data_product: Option<String>, pub tenant: Option<String>, pub description: Option<Description>, pub schema: Vec<SchemaObject>, pub servers: Vec<Server>, pub team: Option<Team>, pub support: Option<Support>, pub roles: Vec<Role>, pub service_levels: Vec<ServiceLevel>, pub quality: Vec<QualityRule>, pub price: Option<Price>, pub terms: Option<Terms>, pub links: Vec<Link>, pub authoritative_definitions: Vec<AuthoritativeDefinition>, pub tags: Vec<String>, pub custom_properties: Vec<CustomProperty>, pub contract_created_ts: Option<String>,
}
Expand description

ODCSContract - the root data contract document (ODCS v3.1.0)

This is the top-level structure that represents an entire ODCS data contract. It contains all contract-level metadata plus one or more schema objects (tables).

§Example

use data_modelling_core::models::odcs::{ODCSContract, SchemaObject, Property};

let contract = ODCSContract::new("customer-contract", "v1.0.0")
    .with_domain("retail")
    .with_status("active")
    .with_schema(
        SchemaObject::new("customers")
            .with_physical_type("table")
            .with_properties(vec![
                Property::new("id", "integer").with_primary_key(true),
                Property::new("name", "string").with_required(true),
            ])
    );

Fields§

§api_version: String

API version (e.g., “v3.1.0”)

§kind: String

Kind identifier (always “DataContract”)

§id: String

Unique contract ID (UUID or other identifier)

§version: String

Contract version (semantic versioning recommended)

§name: String

Contract name

§status: Option<String>

Contract status: “draft”, “active”, “deprecated”, “retired”

§domain: Option<String>

Domain this contract belongs to

§data_product: Option<String>

Data product this contract belongs to

§tenant: Option<String>

Tenant identifier for multi-tenant systems

§description: Option<Description>

Contract description (can be simple string or structured object)

§schema: Vec<SchemaObject>

Schema objects (tables, views, topics) in this contract

§servers: Vec<Server>

Server configurations

§team: Option<Team>

Team information

§support: Option<Support>

Support information

§roles: Vec<Role>

Role definitions

§service_levels: Vec<ServiceLevel>

Service level agreements

§quality: Vec<QualityRule>

Contract-level quality rules

§price: Option<Price>

Price information

§terms: Option<Terms>

Terms and conditions

§links: Vec<Link>

External links

§authoritative_definitions: Vec<AuthoritativeDefinition>

Authoritative definitions

§tags: Vec<String>

Contract-level tags

§custom_properties: Vec<CustomProperty>

Custom properties for format-specific metadata

§contract_created_ts: Option<String>

Contract creation timestamp (ISO 8601)

Implementations§

Source§

impl ODCSContract

Source

pub fn new(name: impl Into<String>, version: impl Into<String>) -> Self

Create a new contract with the given name and version

Source

pub fn new_with_id( id: impl Into<String>, name: impl Into<String>, version: impl Into<String>, ) -> Self

Create a new contract with a specific ID

Source

pub fn with_api_version(self, api_version: impl Into<String>) -> Self

Set the API version

Source

pub fn with_status(self, status: impl Into<String>) -> Self

Set the status

Source

pub fn with_domain(self, domain: impl Into<String>) -> Self

Set the domain

Source

pub fn with_data_product(self, data_product: impl Into<String>) -> Self

Set the data product

Source

pub fn with_tenant(self, tenant: impl Into<String>) -> Self

Set the tenant

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Set the description (simple string)

Source

pub fn with_structured_description(self, description: Description) -> Self

Set a structured description

Source

pub fn with_schema(self, schema: SchemaObject) -> Self

Add a schema object

Source

pub fn with_schemas(self, schemas: Vec<SchemaObject>) -> Self

Set all schema objects

Source

pub fn with_server(self, server: Server) -> Self

Add a server configuration

Source

pub fn with_team(self, team: Team) -> Self

Set the team information

Source

pub fn with_support(self, support: Support) -> Self

Set the support information

Source

pub fn with_role(self, role: Role) -> Self

Add a role

Source

pub fn with_service_level(self, service_level: ServiceLevel) -> Self

Add a service level

Source

pub fn with_quality_rule(self, rule: QualityRule) -> Self

Add a quality rule

Source

pub fn with_price(self, price: Price) -> Self

Set the price

Source

pub fn with_terms(self, terms: Terms) -> Self

Set the terms

Add a link

Source

pub fn with_authoritative_definition( self, definition: AuthoritativeDefinition, ) -> Self

Add an authoritative definition

Source

pub fn with_tag(self, tag: impl Into<String>) -> Self

Add a tag

Source

pub fn with_tags(self, tags: Vec<String>) -> Self

Set all tags

Source

pub fn with_custom_property(self, custom_property: CustomProperty) -> Self

Add a custom property

Source

pub fn with_contract_created_ts(self, timestamp: impl Into<String>) -> Self

Set the contract creation timestamp

Source

pub fn schema_count(&self) -> usize

Get the number of schema objects

Source

pub fn get_schema(&self, name: &str) -> Option<&SchemaObject>

Get a schema object by name

Source

pub fn get_schema_mut(&mut self, name: &str) -> Option<&mut SchemaObject>

Get a mutable schema object by name

Source

pub fn schema_names(&self) -> Vec<&str>

Get all schema names

Source

pub fn is_multi_table(&self) -> bool

Check if this is a multi-table contract

Source

pub fn first_schema(&self) -> Option<&SchemaObject>

Get the first schema (for single-table contracts)

Source

pub fn description_string(&self) -> Option<String>

Get the description as a simple string

Source§

impl ODCSContract

Source

pub fn to_tables(&self) -> Vec<Table>

Convert the contract to a vector of Tables

Each SchemaObject becomes a Table, with contract-level metadata stored in each table’s odcl_metadata.

Source

pub fn from_tables(tables: &[Table]) -> Self

Create a contract from a vector of Tables

Contract-level metadata is extracted from the first table’s odcl_metadata. Each table becomes a SchemaObject.

Source

pub fn to_table_data(&self) -> Vec<TableData>

Convert contract to TableData for API responses

Trait Implementations§

Source§

impl Clone for ODCSContract

Source§

fn clone(&self) -> ODCSContract

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ODCSContract

Source§

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

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

impl Default for ODCSContract

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ODCSContract

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 PartialEq for ODCSContract

Source§

fn eq(&self, other: &ODCSContract) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ODCSContract

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
Source§

impl StructuralPartialEq for ODCSContract

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> 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> 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
Source§

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