// @generated by `zero-rust codegen` from packages/zero-swift-cli/test/sweep-schema.ts. Do not edit. // // Declare it as `#[rustfmt::skip] mod schema;`: rustfmt would reformat it, // and `zero-rust codegen --check` compares it as generated. #![allow(dead_code)] use ::zero_client::typed as z; /// A row of `a-b`. #[derive(Clone, Debug, PartialEq)] pub struct AB { pub id: String, } impl AB { pub const ID: z::Column = z::Column::new("id"); } impl z::QueryElement for AB { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(AB { id: z::column(entry, "id", 0)?, }) } } impl z::ZeroRow for AB { const TABLE: &'static str = "a-b"; type Update = ABUpdate; type Key = ABKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } impl z::OptionalQueryElement for AB { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::a_b_(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct ABUpdate { pub id: String, } impl z::ColumnValues for ABUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// What `mutate::a_b_(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct ABKey { pub id: String, } impl z::ColumnValues for ABKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `a_b`. #[derive(Clone, Debug, PartialEq)] pub struct ABRow { pub id: String, } impl ABRow { pub const ID: z::Column = z::Column::new("id"); } impl z::QueryElement for ABRow { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(ABRow { id: z::column(entry, "id", 0)?, }) } } impl z::ZeroRow for ABRow { const TABLE: &'static str = "a_b"; type Update = ABRowUpdate; type Key = ABRowKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } impl z::OptionalQueryElement for ABRow { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::a_b(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct ABRowUpdate { pub id: String, } impl z::ColumnValues for ABRowUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// What `mutate::a_b(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct ABRowKey { pub id: String, } impl z::ColumnValues for ABRowKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// A row of `init`. #[derive(Clone, Debug, PartialEq)] pub struct Init { pub id: String, } impl Init { pub const ID: z::Column = z::Column::new("id"); } impl z::QueryElement for Init { fn from_entry(entry: &z::ViewEntry) -> Result { Ok(Init { id: z::column(entry, "id", 0)?, }) } } impl z::ZeroRow for Init { const TABLE: &'static str = "init"; type Update = InitUpdate; type Key = InitKey; fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } impl z::OptionalQueryElement for Init { fn optional_from_view(view: &z::ViewValue) -> Result, z::ZeroValueError> { z::optional_row(view) } } /// What `mutate::init(tx).update` takes: the primary key, and the other columns to set. A column that is `None`, or `ColumnUpdate::Unchanged`, keeps its value. #[derive(Clone, Debug, PartialEq)] pub struct InitUpdate { pub id: String, } impl z::ColumnValues for InitUpdate { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// What `mutate::init(tx).delete` takes: the primary key. #[derive(Clone, Debug, PartialEq)] pub struct InitKey { pub id: String, } impl z::ColumnValues for InitKey { fn column_values(&self) -> z::Object { let mut row = z::Object::with_capacity(1); row.insert("id", z::ZeroValue::to_zero_value(&self.id)); row } } /// The schema the queries of `zql` are over. pub fn schema() -> ::std::sync::Arc { static SCHEMA: ::std::sync::OnceLock<::std::sync::Arc> = ::std::sync::OnceLock::new(); SCHEMA.get_or_init(|| z::schema_from_json(r#"{ "tables": { "a-b": { "name": "a-b", "columns": { "id": { "type": "string" } }, "primaryKey": [ "id" ] }, "a_b": { "name": "a_b", "columns": { "id": { "type": "string" } }, "primaryKey": [ "id" ] }, "init": { "name": "init", "columns": { "id": { "type": "string" } }, "primaryKey": [ "id" ] } }, "relationships": {} }"#)).clone() } /// The queries of the schema, one per table: `zql::a_b()`. pub mod zql { /// The rows of `a-b`. pub fn a_b_() -> super::z::Query { super::z::Query::table(super::schema()) } /// The rows of `a_b`. pub fn a_b() -> super::z::Query { super::z::Query::table(super::schema()) } /// The rows of `init`. pub fn init() -> super::z::Query { super::z::Query::table(super::schema()) } } /// The CRUD operations of a mutator, one per table: `mutate::a_b_(tx).insert(&row)`. pub mod mutate { /// Inserts, upserts, updates, and deletes rows of `a-b`. pub fn a_b_(tx: &super::z::Transaction) -> super::z::TypedTableMutator<'_, super::AB> { super::z::TypedTableMutator::new(tx) } /// Inserts, upserts, updates, and deletes rows of `a_b`. pub fn a_b(tx: &super::z::Transaction) -> super::z::TypedTableMutator<'_, super::ABRow> { super::z::TypedTableMutator::new(tx) } /// Inserts, upserts, updates, and deletes rows of `init`. pub fn init(tx: &super::z::Transaction) -> super::z::TypedTableMutator<'_, super::Init> { super::z::TypedTableMutator::new(tx) } }