diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d770038 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [0.1.1] - 2025-04-23 + +### πŸ’Ό Other + +- Alpha release + +### 🚜 Refactor + +- Make Cargo.toml version easy to bump version + +### πŸ“š Documentation + +- Add repository link +- Document features +- Document all features and enable optional features + +### βš™οΈ Miscellaneous Tasks + +- Add check workflow (#1) +- Update cargo manifest files +- Rename macros crate +- Update doc link +- Remove expanded file +- Add release script + + diff --git a/Cargo.lock b/Cargo.lock index 84a3c8c..4b75c4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,7 +409,7 @@ dependencies = [ [[package]] name = "example-kitchen-sink" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "chrono", @@ -428,7 +428,7 @@ dependencies = [ [[package]] name = "example-todo" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "chrono", @@ -447,7 +447,7 @@ dependencies = [ [[package]] name = "example-todo-postgres" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "chrono", @@ -977,12 +977,12 @@ dependencies = [ [[package]] name = "lazybe" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "axum", "chrono", - "lazybe-macro", + "lazybe-macros", "sea-query", "serde", "serde_json", @@ -994,8 +994,8 @@ dependencies = [ ] [[package]] -name = "lazybe-macro" -version = "0.1.0" +name = "lazybe-macros" +version = "0.1.1" dependencies = [ "convert_case", "darling", diff --git a/Cargo.toml b/Cargo.toml index 02a57bf..a37b15f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,14 @@ [workspace] resolver = "3" -members = ["examples/*", "lazybe", "lazybe-macro"] +members = ["examples/*", "lazybe", "lazybe-macros"] [workspace.package] -version = "0.1.0" +version = "0.1.1" # bump edition = "2024" authors = ["Pat Losoponkul "] +license = "Apache-2.0" +homepage = "https://github.com/patextreme/lazybe" +repository = "https://github.com/patextreme/lazybe" [workspace.dependencies] anyhow = "1" diff --git a/README.md b/README.md index c055e29..3dcb384 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,16 @@ For a complete working example, see the [minimal API example](./examples/kitchen # Documentation -The only documentation for now is the [example directory](./examples). There’s no fancy doc site just yet. +- [Example directory](./examples) +- [docs.rs](https://docs.rs/lazybe/latest/lazybe/) + +# Releasing + +```bash +# Prepare a new version, then merge the PR and create a tag +nix run .#bump + +# Publish to crates.io +cargo publish -p lazybe-macros +cargo publish -p lazybe +``` diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..88ef381 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,88 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# template for the changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ + +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] +# render body even when there are no releases to process +# render_always = true +# output file path +# output = "test.md" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "πŸš€ Features" }, + { message = "^fix", group = "πŸ› Bug Fixes" }, + { message = "^doc", group = "πŸ“š Documentation" }, + { message = "^perf", group = "⚑ Performance" }, + { message = "^refactor", group = "🚜 Refactor" }, + { message = "^style", group = "🎨 Styling" }, + { message = "^test", group = "πŸ§ͺ Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "βš™οΈ Miscellaneous Tasks" }, + { body = ".*security", group = "πŸ›‘οΈ Security" }, + { message = "^revert", group = "◀️ Revert" }, + { message = ".*", group = "πŸ’Ό Other" }, +] +# filter out the commits that are not matched by commit parsers +filter_commits = false +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +tag_pattern = "v[0-9].*" + +[bump] +initial_tag = "v0.1.1" diff --git a/examples/kitchen-sink/Cargo.toml b/examples/kitchen-sink/Cargo.toml index 1555923..6256ea1 100644 --- a/examples/kitchen-sink/Cargo.toml +++ b/examples/kitchen-sink/Cargo.toml @@ -3,6 +3,7 @@ name = "example-kitchen-sink" version.workspace = true edition.workspace = true authors.workspace = true +publish = false [dependencies] anyhow = { workspace = true } diff --git a/examples/todo-postgres/Cargo.toml b/examples/todo-postgres/Cargo.toml index bda993e..4010a41 100644 --- a/examples/todo-postgres/Cargo.toml +++ b/examples/todo-postgres/Cargo.toml @@ -3,6 +3,7 @@ name = "example-todo-postgres" version.workspace = true edition.workspace = true authors.workspace = true +publish = false [dependencies] anyhow = { workspace = true } diff --git a/examples/todo/Cargo.toml b/examples/todo/Cargo.toml index e78202c..c0220e8 100644 --- a/examples/todo/Cargo.toml +++ b/examples/todo/Cargo.toml @@ -3,6 +3,7 @@ name = "example-todo" version.workspace = true edition.workspace = true authors.workspace = true +publish = false [dependencies] anyhow = { workspace = true } diff --git a/flake.nix b/flake.nix index add7210..27a0965 100644 --- a/flake.nix +++ b/flake.nix @@ -57,6 +57,44 @@ }; }; + apps = { + bump = { + type = "app"; + program = + (pkgs.writeShellApplication { + name = "bump"; + runtimeInputs = with pkgs; [ + git-cliff + jq + rust + taplo + ]; + text = '' + NEW_VERSION=$(git-cliff --bump --context | jq -r .[0].version | sed s/^v//) + NEW_VERSION_TAG="v$NEW_VERSION" + + echo "Preparing a new version: $NEW_VERSION (tag: $NEW_VERSION_TAG)" + git-cliff --bump -o CHANGELOG.md + sed -i -E "s/^version = .*\# bump$/version = \"$NEW_VERSION\" # bump/" Cargo.toml + sed -i -E "s/^version = .*\# bump$/version = \"$NEW_VERSION\" # bump/" lazybe/Cargo.toml + + find . | grep '\.toml$' | xargs -I _ bash -c "echo running taplo on _ && taplo format _" + + cargo update lazybe-macros --precise "$NEW_VERSION" + cargo update lazybe --precise "$NEW_VERSION" + git add CHANGELOG.md + git add Cargo.lock + git add Cargo.toml + git add lazybe/Cargo.toml + + printf "\nPlease verify if everything is ok, then run the following command ...\n" + echo "> git commit -m \"chore(release): prepare for $NEW_VERSION release\"" + ''; + }).outPath + + "/bin/bump"; + }; + }; + devShells.default = let rootDir = "$ROOT_DIR"; @@ -98,6 +136,7 @@ # base curl git + git-cliff hurl jq less diff --git a/lazybe-macro/Cargo.toml b/lazybe-macros/Cargo.toml similarity index 54% rename from lazybe-macro/Cargo.toml rename to lazybe-macros/Cargo.toml index d53e230..451b4f3 100644 --- a/lazybe-macro/Cargo.toml +++ b/lazybe-macros/Cargo.toml @@ -1,8 +1,13 @@ [package] -name = "lazybe-macro" +name = "lazybe-macros" +description = "Proc macro for lazybe crate" version.workspace = true edition.workspace = true authors.workspace = true +license.workspace = true +readme = "../README.md" +homepage.workspace = true +repository.workspace = true [lib] proc-macro = true diff --git a/lazybe-macro/src/common.rs b/lazybe-macros/src/common.rs similarity index 100% rename from lazybe-macro/src/common.rs rename to lazybe-macros/src/common.rs diff --git a/lazybe-macro/src/entity.rs b/lazybe-macros/src/entity.rs similarity index 100% rename from lazybe-macro/src/entity.rs rename to lazybe-macros/src/entity.rs diff --git a/lazybe-macro/src/entity_endpoint.rs b/lazybe-macros/src/entity_endpoint.rs similarity index 100% rename from lazybe-macro/src/entity_endpoint.rs rename to lazybe-macros/src/entity_endpoint.rs diff --git a/lazybe-macro/src/enum.rs b/lazybe-macros/src/enum.rs similarity index 100% rename from lazybe-macro/src/enum.rs rename to lazybe-macros/src/enum.rs diff --git a/lazybe-macro/src/lib.rs b/lazybe-macros/src/lib.rs similarity index 100% rename from lazybe-macro/src/lib.rs rename to lazybe-macros/src/lib.rs diff --git a/lazybe-macro/src/newtype.rs b/lazybe-macros/src/newtype.rs similarity index 100% rename from lazybe-macro/src/newtype.rs rename to lazybe-macros/src/newtype.rs diff --git a/lazybe/Cargo.toml b/lazybe/Cargo.toml index 2982f76..148afed 100644 --- a/lazybe/Cargo.toml +++ b/lazybe/Cargo.toml @@ -1,12 +1,20 @@ [package] name = "lazybe" +description = "Derive boring CRUD API boilerplate for Rust backend" version.workspace = true edition.workspace = true authors.workspace = true +license.workspace = true +readme = "../README.md" +homepage.workspace = true +repository.workspace = true + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] [dependencies] # core -lazybe-macro = { path = "../lazybe-macro" } tracing = { workspace = true } sea-query = { workspace = true } serde = { workspace = true } @@ -17,6 +25,10 @@ uuid = { workspace = true, features = ["v4"] } axum = { workspace = true, optional = true } utoipa = { workspace = true, optional = true } +[dependencies.lazybe-macros] +path = "../lazybe-macros" +version = "0.1.1" # bump + [dev-dependencies] anyhow = { workspace = true } axum = { workspace = true } @@ -26,7 +38,7 @@ serde_json = { workspace = true } [features] default = [] -sqlite = [] -postgres = [] +sqlite = ["sqlx/sqlite"] +postgres = ["sqlx/postgres"] axum = ["dep:axum"] openapi = ["axum", "dep:utoipa"] diff --git a/lazybe/src/db.rs b/lazybe/src/db.rs index fbb95ab..ebcfc41 100644 --- a/lazybe/src/db.rs +++ b/lazybe/src/db.rs @@ -15,6 +15,7 @@ pub trait DbCtx { /// Integraion with sqlite database #[cfg(feature = "sqlite")] +#[doc(cfg(feature = "sqlite"))] pub mod sqlite { use sea_query::SqliteQueryBuilder; use sqlx::Sqlite; @@ -35,6 +36,7 @@ pub mod sqlite { /// Integraion with postgres database #[cfg(feature = "postgres")] +#[doc(cfg(feature = "postgres"))] pub mod postgres { use sea_query::PostgresQueryBuilder; use sqlx::Postgres; diff --git a/lazybe/src/lib.rs b/lazybe/src/lib.rs index 7f05251..2b25cf1 100644 --- a/lazybe/src/lib.rs +++ b/lazybe/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(doc_cfg)] + //! A building block for quickly (and lazily) creating CRUD backend applications. //! //! When building a backend application in Rust, you'll often need to expose resources @@ -474,19 +476,22 @@ pub mod uuid { /// Re-exports of proc-macro pub mod macros { - pub use lazybe_macro::*; + pub use lazybe_macros::*; } /// Module implementing [`axum`] router #[cfg(feature = "axum")] +#[doc(cfg(feature = "axum"))] pub mod router; /// Re-exports of [`axum`] #[cfg(feature = "axum")] +#[doc(cfg(feature = "axum"))] pub mod axum { pub use axum::*; } /// Utilities for generating a OpenAPI documentation #[cfg(feature = "openapi")] +#[doc(cfg(feature = "openapi"))] pub mod openapi; diff --git a/lazybe/src/router.rs b/lazybe/src/router.rs index 7bd642d..04fed99 100644 --- a/lazybe/src/router.rs +++ b/lazybe/src/router.rs @@ -265,12 +265,14 @@ impl ResultExt for Result { } #[cfg(feature = "sqlite")] +#[doc(cfg(feature = "sqlite"))] pub mod sqlite { super::macros::axum_route_impl_imports!(); super::macros::axum_route_impl!(sqlx::Sqlite, crate::db::sqlite::SqliteDbCtx); } #[cfg(feature = "postgres")] +#[doc(cfg(feature = "postgres"))] pub mod postgres { super::macros::axum_route_impl_imports!(); super::macros::axum_route_impl!(sqlx::Postgres, crate::db::postgres::PostgresDbCtx); diff --git a/tmp_expand.rs b/tmp_expand.rs deleted file mode 100644 index 1338e8b..0000000 --- a/tmp_expand.rs +++ /dev/null @@ -1,2784 +0,0 @@ -mod todo { - use lazybe::macros::{Entity, Enum, Newtype}; - use serde::{Deserialize, Serialize}; - use sqlx::types::chrono::{DateTime, Utc}; - use utoipa::ToSchema; - pub struct TodoId(u64); - #[automatically_derived] - impl ::core::fmt::Debug for TodoId { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_tuple_field1_finish(f, "TodoId", &&self.0) - } - } - #[automatically_derived] - impl ::core::clone::Clone for TodoId { - #[inline] - fn clone(&self) -> TodoId { - TodoId(::core::clone::Clone::clone(&self.0)) - } - } - #[automatically_derived] - impl ::core::marker::StructuralPartialEq for TodoId {} - #[automatically_derived] - impl ::core::cmp::PartialEq for TodoId { - #[inline] - fn eq(&self, other: &TodoId) -> bool { - self.0 == other.0 - } - } - #[automatically_derived] - impl ::core::cmp::Eq for TodoId { - #[inline] - #[doc(hidden)] - #[coverage(off)] - fn assert_receiver_is_total_eq(&self) -> () { - let _: ::core::cmp::AssertParamIsEq; - } - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for TodoId { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - _serde::Serializer::serialize_newtype_struct( - __serializer, - "TodoId", - &self.0, - ) - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for TodoId { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = TodoId; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "tuple struct TodoId", - ) - } - #[inline] - fn visit_newtype_struct<__E>( - self, - __e: __E, - ) -> _serde::__private::Result - where - __E: _serde::Deserializer<'de>, - { - let __field0: u64 = ::deserialize( - __e, - )?; - _serde::__private::Ok(TodoId(__field0)) - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = match _serde::de::SeqAccess::next_element::< - u64, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 0usize, - &"tuple struct TodoId with 1 element", - ), - ); - } - }; - _serde::__private::Ok(TodoId(__field0)) - } - } - _serde::Deserializer::deserialize_newtype_struct( - __deserializer, - "TodoId", - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - impl<'r, Db> sqlx::Decode<'r, Db> for TodoId - where - Db: sqlx::Database, - for<'s> u64: sqlx::Decode<'s, Db>, - { - fn decode( - value: ::ValueRef<'r>, - ) -> Result { - let inner_value = >::decode(value)?; - Ok(TodoId(inner_value)) - } - } - impl sqlx::Type for TodoId - where - Db: sqlx::Database, - u64: sqlx::Type, - { - fn type_info() -> ::TypeInfo { - >::type_info() - } - } - impl From for sea_query::Value { - fn from(value: TodoId) -> Self { - value.0.into() - } - } - impl sea_query::Nullable for TodoId { - fn null() -> sea_query::Value { - ::null() - } - } - impl utoipa::__dev::ComposeSchema for TodoId { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::Integer, - ), - ) - .format( - Some( - utoipa::openapi::schema::SchemaFormat::KnownFormat( - utoipa::openapi::schema::KnownFormat::Int64, - ), - ), - ) - .minimum(Some(0f64)) - .into() - } - } - impl utoipa::ToSchema for TodoId { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("TodoId") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas.extend([]); - } - } - #[lazybe(table = "todo", endpoint = "/todos", derive_to_schema)] - pub struct Todo { - #[lazybe(primary_key, generate_with = "fourty_two")] - pub id: TodoId, - pub title: String, - pub description: Option, - pub status: Status, - #[lazybe(created_at)] - pub created_at: DateTime, - #[lazybe(updated_at)] - pub updated_at: DateTime, - } - #[automatically_derived] - impl ::core::fmt::Debug for Todo { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - let names: &'static _ = &[ - "id", - "title", - "description", - "status", - "created_at", - "updated_at", - ]; - let values: &[&dyn ::core::fmt::Debug] = &[ - &self.id, - &self.title, - &self.description, - &self.status, - &self.created_at, - &&self.updated_at, - ]; - ::core::fmt::Formatter::debug_struct_fields_finish(f, "Todo", names, values) - } - } - #[automatically_derived] - impl ::core::clone::Clone for Todo { - #[inline] - fn clone(&self) -> Todo { - Todo { - id: ::core::clone::Clone::clone(&self.id), - title: ::core::clone::Clone::clone(&self.title), - description: ::core::clone::Clone::clone(&self.description), - status: ::core::clone::Clone::clone(&self.status), - created_at: ::core::clone::Clone::clone(&self.created_at), - updated_at: ::core::clone::Clone::clone(&self.updated_at), - } - } - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for Todo { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - let mut __serde_state = _serde::Serializer::serialize_struct( - __serializer, - "Todo", - false as usize + 1 + 1 + 1 + 1 + 1 + 1, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "id", - &self.id, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "title", - &self.title, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "description", - &self.description, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "status", - &self.status, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "created_at", - &self.created_at, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "updated_at", - &self.updated_at, - )?; - _serde::ser::SerializeStruct::end(__serde_state) - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for Todo { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - #[doc(hidden)] - enum __Field { - __field0, - __field1, - __field2, - __field3, - __field4, - __field5, - __ignore, - } - #[doc(hidden)] - struct __FieldVisitor; - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "field identifier", - ) - } - fn visit_u64<__E>( - self, - __value: u64, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::__private::Ok(__Field::__field0), - 1u64 => _serde::__private::Ok(__Field::__field1), - 2u64 => _serde::__private::Ok(__Field::__field2), - 3u64 => _serde::__private::Ok(__Field::__field3), - 4u64 => _serde::__private::Ok(__Field::__field4), - 5u64 => _serde::__private::Ok(__Field::__field5), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_str<__E>( - self, - __value: &str, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - "id" => _serde::__private::Ok(__Field::__field0), - "title" => _serde::__private::Ok(__Field::__field1), - "description" => _serde::__private::Ok(__Field::__field2), - "status" => _serde::__private::Ok(__Field::__field3), - "created_at" => _serde::__private::Ok(__Field::__field4), - "updated_at" => _serde::__private::Ok(__Field::__field5), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - b"id" => _serde::__private::Ok(__Field::__field0), - b"title" => _serde::__private::Ok(__Field::__field1), - b"description" => _serde::__private::Ok(__Field::__field2), - b"status" => _serde::__private::Ok(__Field::__field3), - b"created_at" => _serde::__private::Ok(__Field::__field4), - b"updated_at" => _serde::__private::Ok(__Field::__field5), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - } - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier( - __deserializer, - __FieldVisitor, - ) - } - } - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = Todo; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "struct Todo", - ) - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = match _serde::de::SeqAccess::next_element::< - TodoId, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 0usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - let __field1 = match _serde::de::SeqAccess::next_element::< - String, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 1usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - let __field2 = match _serde::de::SeqAccess::next_element::< - Option, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 2usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - let __field3 = match _serde::de::SeqAccess::next_element::< - Status, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 3usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - let __field4 = match _serde::de::SeqAccess::next_element::< - DateTime, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 4usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - let __field5 = match _serde::de::SeqAccess::next_element::< - DateTime, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 5usize, - &"struct Todo with 6 elements", - ), - ); - } - }; - _serde::__private::Ok(Todo { - id: __field0, - title: __field1, - description: __field2, - status: __field3, - created_at: __field4, - updated_at: __field5, - }) - } - #[inline] - fn visit_map<__A>( - self, - mut __map: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::MapAccess<'de>, - { - let mut __field0: _serde::__private::Option = _serde::__private::None; - let mut __field1: _serde::__private::Option = _serde::__private::None; - let mut __field2: _serde::__private::Option> = _serde::__private::None; - let mut __field3: _serde::__private::Option = _serde::__private::None; - let mut __field4: _serde::__private::Option> = _serde::__private::None; - let mut __field5: _serde::__private::Option> = _serde::__private::None; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key::< - __Field, - >(&mut __map)? { - match __key { - __Field::__field0 => { - if _serde::__private::Option::is_some(&__field0) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("id"), - ); - } - __field0 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - __Field::__field1 => { - if _serde::__private::Option::is_some(&__field1) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("title"), - ); - } - __field1 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - __Field::__field2 => { - if _serde::__private::Option::is_some(&__field2) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "description", - ), - ); - } - __field2 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option, - >(&mut __map)?, - ); - } - __Field::__field3 => { - if _serde::__private::Option::is_some(&__field3) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("status"), - ); - } - __field3 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - __Field::__field4 => { - if _serde::__private::Option::is_some(&__field4) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "created_at", - ), - ); - } - __field4 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - DateTime, - >(&mut __map)?, - ); - } - __Field::__field5 => { - if _serde::__private::Option::is_some(&__field5) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "updated_at", - ), - ); - } - __field5 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - DateTime, - >(&mut __map)?, - ); - } - _ => { - let _ = _serde::de::MapAccess::next_value::< - _serde::de::IgnoredAny, - >(&mut __map)?; - } - } - } - let __field0 = match __field0 { - _serde::__private::Some(__field0) => __field0, - _serde::__private::None => { - _serde::__private::de::missing_field("id")? - } - }; - let __field1 = match __field1 { - _serde::__private::Some(__field1) => __field1, - _serde::__private::None => { - _serde::__private::de::missing_field("title")? - } - }; - let __field2 = match __field2 { - _serde::__private::Some(__field2) => __field2, - _serde::__private::None => { - _serde::__private::de::missing_field("description")? - } - }; - let __field3 = match __field3 { - _serde::__private::Some(__field3) => __field3, - _serde::__private::None => { - _serde::__private::de::missing_field("status")? - } - }; - let __field4 = match __field4 { - _serde::__private::Some(__field4) => __field4, - _serde::__private::None => { - _serde::__private::de::missing_field("created_at")? - } - }; - let __field5 = match __field5 { - _serde::__private::Some(__field5) => __field5, - _serde::__private::None => { - _serde::__private::de::missing_field("updated_at")? - } - }; - _serde::__private::Ok(Todo { - id: __field0, - title: __field1, - description: __field2, - status: __field3, - created_at: __field4, - updated_at: __field5, - }) - } - } - #[doc(hidden)] - const FIELDS: &'static [&'static str] = &[ - "id", - "title", - "description", - "status", - "created_at", - "updated_at", - ]; - _serde::Deserializer::deserialize_struct( - __deserializer, - "Todo", - FIELDS, - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - pub struct CreateTodo { - pub title: String, - pub description: Option, - pub status: Status, - } - impl utoipa::__dev::ComposeSchema for CreateTodo { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - { - let mut object = utoipa::openapi::ObjectBuilder::new(); - object = object - .property( - "title", - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ), - ) - .required("title"); - object = object - .property( - "description", - utoipa::openapi::ObjectBuilder::new() - .schema_type({ - use std::iter::FromIterator; - utoipa::openapi::schema::SchemaType::from_iter([ - utoipa::openapi::schema::Type::String, - utoipa::openapi::schema::Type::Null, - ]) - }), - ); - object = object - .property( - "status", - utoipa::openapi::schema::RefBuilder::new() - .ref_location_from_schema_name( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ) - .required("status"); - object - } - .into() - } - } - impl utoipa::ToSchema for CreateTodo { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("CreateTodo") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas - .extend([ - ( - String::from( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ::schema(), - ), - ]); - ::schemas(schemas); - } - } - #[automatically_derived] - impl ::core::fmt::Debug for CreateTodo { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_struct_field3_finish( - f, - "CreateTodo", - "title", - &self.title, - "description", - &self.description, - "status", - &&self.status, - ) - } - } - #[automatically_derived] - impl ::core::clone::Clone for CreateTodo { - #[inline] - fn clone(&self) -> CreateTodo { - CreateTodo { - title: ::core::clone::Clone::clone(&self.title), - description: ::core::clone::Clone::clone(&self.description), - status: ::core::clone::Clone::clone(&self.status), - } - } - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for CreateTodo { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - let mut __serde_state = _serde::Serializer::serialize_struct( - __serializer, - "CreateTodo", - false as usize + 1 + 1 + 1, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "title", - &self.title, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "description", - &self.description, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "status", - &self.status, - )?; - _serde::ser::SerializeStruct::end(__serde_state) - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for CreateTodo { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - #[doc(hidden)] - enum __Field { - __field0, - __field1, - __field2, - __ignore, - } - #[doc(hidden)] - struct __FieldVisitor; - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "field identifier", - ) - } - fn visit_u64<__E>( - self, - __value: u64, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::__private::Ok(__Field::__field0), - 1u64 => _serde::__private::Ok(__Field::__field1), - 2u64 => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_str<__E>( - self, - __value: &str, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - "title" => _serde::__private::Ok(__Field::__field0), - "description" => _serde::__private::Ok(__Field::__field1), - "status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - b"title" => _serde::__private::Ok(__Field::__field0), - b"description" => _serde::__private::Ok(__Field::__field1), - b"status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - } - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier( - __deserializer, - __FieldVisitor, - ) - } - } - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = CreateTodo; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "struct CreateTodo", - ) - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = match _serde::de::SeqAccess::next_element::< - String, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 0usize, - &"struct CreateTodo with 3 elements", - ), - ); - } - }; - let __field1 = match _serde::de::SeqAccess::next_element::< - Option, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 1usize, - &"struct CreateTodo with 3 elements", - ), - ); - } - }; - let __field2 = match _serde::de::SeqAccess::next_element::< - Status, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 2usize, - &"struct CreateTodo with 3 elements", - ), - ); - } - }; - _serde::__private::Ok(CreateTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - #[inline] - fn visit_map<__A>( - self, - mut __map: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::MapAccess<'de>, - { - let mut __field0: _serde::__private::Option = _serde::__private::None; - let mut __field1: _serde::__private::Option> = _serde::__private::None; - let mut __field2: _serde::__private::Option = _serde::__private::None; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key::< - __Field, - >(&mut __map)? { - match __key { - __Field::__field0 => { - if _serde::__private::Option::is_some(&__field0) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("title"), - ); - } - __field0 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - __Field::__field1 => { - if _serde::__private::Option::is_some(&__field1) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "description", - ), - ); - } - __field1 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option, - >(&mut __map)?, - ); - } - __Field::__field2 => { - if _serde::__private::Option::is_some(&__field2) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("status"), - ); - } - __field2 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - _ => { - let _ = _serde::de::MapAccess::next_value::< - _serde::de::IgnoredAny, - >(&mut __map)?; - } - } - } - let __field0 = match __field0 { - _serde::__private::Some(__field0) => __field0, - _serde::__private::None => { - _serde::__private::de::missing_field("title")? - } - }; - let __field1 = match __field1 { - _serde::__private::Some(__field1) => __field1, - _serde::__private::None => { - _serde::__private::de::missing_field("description")? - } - }; - let __field2 = match __field2 { - _serde::__private::Some(__field2) => __field2, - _serde::__private::None => { - _serde::__private::de::missing_field("status")? - } - }; - _serde::__private::Ok(CreateTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - } - #[doc(hidden)] - const FIELDS: &'static [&'static str] = &[ - "title", - "description", - "status", - ]; - _serde::Deserializer::deserialize_struct( - __deserializer, - "CreateTodo", - FIELDS, - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - pub struct UpdateTodo { - pub title: Option, - pub description: Option>, - pub status: Option, - } - impl utoipa::__dev::ComposeSchema for UpdateTodo { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - { - let mut object = utoipa::openapi::ObjectBuilder::new(); - object = object - .property( - "title", - utoipa::openapi::ObjectBuilder::new() - .schema_type({ - use std::iter::FromIterator; - utoipa::openapi::schema::SchemaType::from_iter([ - utoipa::openapi::schema::Type::String, - utoipa::openapi::schema::Type::Null, - ]) - }), - ); - object = object - .property( - "description", - utoipa::openapi::ObjectBuilder::new() - .schema_type({ - use std::iter::FromIterator; - utoipa::openapi::schema::SchemaType::from_iter([ - utoipa::openapi::schema::Type::String, - utoipa::openapi::schema::Type::Null, - ]) - }), - ); - object = object - .property( - "status", - utoipa::openapi::schema::OneOfBuilder::new() - .item( - utoipa::openapi::schema::ObjectBuilder::new() - .schema_type(utoipa::openapi::schema::Type::Null), - ) - .item( - utoipa::openapi::schema::RefBuilder::new() - .ref_location_from_schema_name( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ), - ); - object - } - .into() - } - } - impl utoipa::ToSchema for UpdateTodo { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("UpdateTodo") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas - .extend([ - ( - String::from( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ::schema(), - ), - ]); - ::schemas(schemas); - } - } - #[automatically_derived] - impl ::core::fmt::Debug for UpdateTodo { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_struct_field3_finish( - f, - "UpdateTodo", - "title", - &self.title, - "description", - &self.description, - "status", - &&self.status, - ) - } - } - #[automatically_derived] - impl ::core::clone::Clone for UpdateTodo { - #[inline] - fn clone(&self) -> UpdateTodo { - UpdateTodo { - title: ::core::clone::Clone::clone(&self.title), - description: ::core::clone::Clone::clone(&self.description), - status: ::core::clone::Clone::clone(&self.status), - } - } - } - #[automatically_derived] - impl ::core::default::Default for UpdateTodo { - #[inline] - fn default() -> UpdateTodo { - UpdateTodo { - title: ::core::default::Default::default(), - description: ::core::default::Default::default(), - status: ::core::default::Default::default(), - } - } - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for UpdateTodo { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - let mut __serde_state = _serde::Serializer::serialize_struct( - __serializer, - "UpdateTodo", - false as usize + 1 + 1 + 1, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "title", - &self.title, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "description", - &self.description, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "status", - &self.status, - )?; - _serde::ser::SerializeStruct::end(__serde_state) - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for UpdateTodo { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - #[doc(hidden)] - enum __Field { - __field0, - __field1, - __field2, - __ignore, - } - #[doc(hidden)] - struct __FieldVisitor; - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "field identifier", - ) - } - fn visit_u64<__E>( - self, - __value: u64, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::__private::Ok(__Field::__field0), - 1u64 => _serde::__private::Ok(__Field::__field1), - 2u64 => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_str<__E>( - self, - __value: &str, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - "title" => _serde::__private::Ok(__Field::__field0), - "description" => _serde::__private::Ok(__Field::__field1), - "status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - b"title" => _serde::__private::Ok(__Field::__field0), - b"description" => _serde::__private::Ok(__Field::__field1), - b"status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - } - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier( - __deserializer, - __FieldVisitor, - ) - } - } - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = UpdateTodo; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "struct UpdateTodo", - ) - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = match _serde::de::SeqAccess::next_element::< - Option, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 0usize, - &"struct UpdateTodo with 3 elements", - ), - ); - } - }; - let __field1 = match _serde::de::SeqAccess::next_element::< - Option>, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 1usize, - &"struct UpdateTodo with 3 elements", - ), - ); - } - }; - let __field2 = match _serde::de::SeqAccess::next_element::< - Option, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 2usize, - &"struct UpdateTodo with 3 elements", - ), - ); - } - }; - _serde::__private::Ok(UpdateTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - #[inline] - fn visit_map<__A>( - self, - mut __map: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::MapAccess<'de>, - { - let mut __field0: _serde::__private::Option> = _serde::__private::None; - let mut __field1: _serde::__private::Option< - Option>, - > = _serde::__private::None; - let mut __field2: _serde::__private::Option> = _serde::__private::None; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key::< - __Field, - >(&mut __map)? { - match __key { - __Field::__field0 => { - if _serde::__private::Option::is_some(&__field0) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("title"), - ); - } - __field0 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option, - >(&mut __map)?, - ); - } - __Field::__field1 => { - if _serde::__private::Option::is_some(&__field1) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "description", - ), - ); - } - __field1 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option>, - >(&mut __map)?, - ); - } - __Field::__field2 => { - if _serde::__private::Option::is_some(&__field2) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("status"), - ); - } - __field2 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option, - >(&mut __map)?, - ); - } - _ => { - let _ = _serde::de::MapAccess::next_value::< - _serde::de::IgnoredAny, - >(&mut __map)?; - } - } - } - let __field0 = match __field0 { - _serde::__private::Some(__field0) => __field0, - _serde::__private::None => { - _serde::__private::de::missing_field("title")? - } - }; - let __field1 = match __field1 { - _serde::__private::Some(__field1) => __field1, - _serde::__private::None => { - _serde::__private::de::missing_field("description")? - } - }; - let __field2 = match __field2 { - _serde::__private::Some(__field2) => __field2, - _serde::__private::None => { - _serde::__private::de::missing_field("status")? - } - }; - _serde::__private::Ok(UpdateTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - } - #[doc(hidden)] - const FIELDS: &'static [&'static str] = &[ - "title", - "description", - "status", - ]; - _serde::Deserializer::deserialize_struct( - __deserializer, - "UpdateTodo", - FIELDS, - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - pub struct ReplaceTodo { - pub title: String, - pub description: Option, - pub status: Status, - } - impl utoipa::__dev::ComposeSchema for ReplaceTodo { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - { - let mut object = utoipa::openapi::ObjectBuilder::new(); - object = object - .property( - "title", - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ), - ) - .required("title"); - object = object - .property( - "description", - utoipa::openapi::ObjectBuilder::new() - .schema_type({ - use std::iter::FromIterator; - utoipa::openapi::schema::SchemaType::from_iter([ - utoipa::openapi::schema::Type::String, - utoipa::openapi::schema::Type::Null, - ]) - }), - ); - object = object - .property( - "status", - utoipa::openapi::schema::RefBuilder::new() - .ref_location_from_schema_name( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ) - .required("status"); - object - } - .into() - } - } - impl utoipa::ToSchema for ReplaceTodo { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("ReplaceTodo") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas - .extend([ - ( - String::from( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ::schema(), - ), - ]); - ::schemas(schemas); - } - } - #[automatically_derived] - impl ::core::fmt::Debug for ReplaceTodo { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_struct_field3_finish( - f, - "ReplaceTodo", - "title", - &self.title, - "description", - &self.description, - "status", - &&self.status, - ) - } - } - #[automatically_derived] - impl ::core::clone::Clone for ReplaceTodo { - #[inline] - fn clone(&self) -> ReplaceTodo { - ReplaceTodo { - title: ::core::clone::Clone::clone(&self.title), - description: ::core::clone::Clone::clone(&self.description), - status: ::core::clone::Clone::clone(&self.status), - } - } - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for ReplaceTodo { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - let mut __serde_state = _serde::Serializer::serialize_struct( - __serializer, - "ReplaceTodo", - false as usize + 1 + 1 + 1, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "title", - &self.title, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "description", - &self.description, - )?; - _serde::ser::SerializeStruct::serialize_field( - &mut __serde_state, - "status", - &self.status, - )?; - _serde::ser::SerializeStruct::end(__serde_state) - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for ReplaceTodo { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - #[doc(hidden)] - enum __Field { - __field0, - __field1, - __field2, - __ignore, - } - #[doc(hidden)] - struct __FieldVisitor; - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "field identifier", - ) - } - fn visit_u64<__E>( - self, - __value: u64, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::__private::Ok(__Field::__field0), - 1u64 => _serde::__private::Ok(__Field::__field1), - 2u64 => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_str<__E>( - self, - __value: &str, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - "title" => _serde::__private::Ok(__Field::__field0), - "description" => _serde::__private::Ok(__Field::__field1), - "status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - b"title" => _serde::__private::Ok(__Field::__field0), - b"description" => _serde::__private::Ok(__Field::__field1), - b"status" => _serde::__private::Ok(__Field::__field2), - _ => _serde::__private::Ok(__Field::__ignore), - } - } - } - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier( - __deserializer, - __FieldVisitor, - ) - } - } - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = ReplaceTodo; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "struct ReplaceTodo", - ) - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = match _serde::de::SeqAccess::next_element::< - String, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 0usize, - &"struct ReplaceTodo with 3 elements", - ), - ); - } - }; - let __field1 = match _serde::de::SeqAccess::next_element::< - Option, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 1usize, - &"struct ReplaceTodo with 3 elements", - ), - ); - } - }; - let __field2 = match _serde::de::SeqAccess::next_element::< - Status, - >(&mut __seq)? { - _serde::__private::Some(__value) => __value, - _serde::__private::None => { - return _serde::__private::Err( - _serde::de::Error::invalid_length( - 2usize, - &"struct ReplaceTodo with 3 elements", - ), - ); - } - }; - _serde::__private::Ok(ReplaceTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - #[inline] - fn visit_map<__A>( - self, - mut __map: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::MapAccess<'de>, - { - let mut __field0: _serde::__private::Option = _serde::__private::None; - let mut __field1: _serde::__private::Option> = _serde::__private::None; - let mut __field2: _serde::__private::Option = _serde::__private::None; - while let _serde::__private::Some(__key) = _serde::de::MapAccess::next_key::< - __Field, - >(&mut __map)? { - match __key { - __Field::__field0 => { - if _serde::__private::Option::is_some(&__field0) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("title"), - ); - } - __field0 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - __Field::__field1 => { - if _serde::__private::Option::is_some(&__field1) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field( - "description", - ), - ); - } - __field1 = _serde::__private::Some( - _serde::de::MapAccess::next_value::< - Option, - >(&mut __map)?, - ); - } - __Field::__field2 => { - if _serde::__private::Option::is_some(&__field2) { - return _serde::__private::Err( - <__A::Error as _serde::de::Error>::duplicate_field("status"), - ); - } - __field2 = _serde::__private::Some( - _serde::de::MapAccess::next_value::(&mut __map)?, - ); - } - _ => { - let _ = _serde::de::MapAccess::next_value::< - _serde::de::IgnoredAny, - >(&mut __map)?; - } - } - } - let __field0 = match __field0 { - _serde::__private::Some(__field0) => __field0, - _serde::__private::None => { - _serde::__private::de::missing_field("title")? - } - }; - let __field1 = match __field1 { - _serde::__private::Some(__field1) => __field1, - _serde::__private::None => { - _serde::__private::de::missing_field("description")? - } - }; - let __field2 = match __field2 { - _serde::__private::Some(__field2) => __field2, - _serde::__private::None => { - _serde::__private::de::missing_field("status")? - } - }; - _serde::__private::Ok(ReplaceTodo { - title: __field0, - description: __field1, - status: __field2, - }) - } - } - #[doc(hidden)] - const FIELDS: &'static [&'static str] = &[ - "title", - "description", - "status", - ]; - _serde::Deserializer::deserialize_struct( - __deserializer, - "ReplaceTodo", - FIELDS, - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - impl From for UpdateTodo { - fn from(value: ReplaceTodo) -> Self { - Self { - title: Some(value.title), - description: Some(value.description), - status: Some(value.status), - } - } - } - pub struct TodoFilter; - #[automatically_derived] - impl ::core::fmt::Debug for TodoFilter { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::write_str(f, "TodoFilter") - } - } - #[automatically_derived] - impl ::core::clone::Clone for TodoFilter { - #[inline] - fn clone(&self) -> TodoFilter { - TodoFilter - } - } - impl TodoFilter { - pub fn id() -> lazybe::filter::FilterCol { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::Id) - } - pub fn title() -> lazybe::filter::FilterCol { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::Title) - } - pub fn description() -> lazybe::filter::FilterCol> { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::Description) - } - pub fn status() -> lazybe::filter::FilterCol { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::Status) - } - pub fn created_at() -> lazybe::filter::FilterCol> { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::CreatedAt) - } - pub fn updated_at() -> lazybe::filter::FilterCol> { - lazybe::filter::FilterCol::new(TodoSeaQueryIdent::UpdatedAt) - } - } - pub struct TodoSort; - #[automatically_derived] - impl ::core::fmt::Debug for TodoSort { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::write_str(f, "TodoSort") - } - } - #[automatically_derived] - impl ::core::clone::Clone for TodoSort { - #[inline] - fn clone(&self) -> TodoSort { - TodoSort - } - } - impl TodoSort { - pub fn id() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::Id) - } - pub fn title() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::Title) - } - pub fn description() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::Description) - } - pub fn status() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::Status) - } - pub fn created_at() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::CreatedAt) - } - pub fn updated_at() -> lazybe::sort::SortCol { - lazybe::sort::SortCol::new(TodoSeaQueryIdent::UpdatedAt) - } - } - pub struct TodoSqlxRow { - id: TodoId, - title: String, - description: Option, - status: Status, - created_at: DateTime, - updated_at: DateTime, - } - #[automatically_derived] - impl<'a, R: ::sqlx::Row> ::sqlx::FromRow<'a, R> for TodoSqlxRow - where - &'a ::std::primitive::str: ::sqlx::ColumnIndex, - TodoId: ::sqlx::decode::Decode<'a, R::Database>, - TodoId: ::sqlx::types::Type, - String: ::sqlx::decode::Decode<'a, R::Database>, - String: ::sqlx::types::Type, - Option: ::sqlx::decode::Decode<'a, R::Database>, - Option: ::sqlx::types::Type, - Status: ::sqlx::decode::Decode<'a, R::Database>, - Status: ::sqlx::types::Type, - DateTime: ::sqlx::decode::Decode<'a, R::Database>, - DateTime: ::sqlx::types::Type, - DateTime: ::sqlx::decode::Decode<'a, R::Database>, - DateTime: ::sqlx::types::Type, - { - fn from_row(__row: &'a R) -> ::sqlx::Result { - let id: TodoId = __row.try_get("id")?; - let title: String = __row.try_get("title")?; - let description: Option = __row.try_get("description")?; - let status: Status = __row.try_get("status")?; - let created_at: DateTime = __row.try_get("created_at")?; - let updated_at: DateTime = __row.try_get("updated_at")?; - ::std::result::Result::Ok(TodoSqlxRow { - id, - title, - description, - status, - created_at, - updated_at, - }) - } - } - impl From for Todo { - fn from(value: TodoSqlxRow) -> Self { - Self { - id: value.id, - title: value.title, - description: value.description, - status: value.status, - created_at: value.created_at, - updated_at: value.updated_at, - } - } - } - #[iden = "todo"] - enum TodoSeaQueryIdent { - Table, - #[iden = "id"] - Id, - #[iden = "title"] - Title, - #[iden = "description"] - Description, - #[iden = "status"] - Status, - #[iden = "created_at"] - CreatedAt, - #[iden = "updated_at"] - UpdatedAt, - } - impl sea_query::Iden for TodoSeaQueryIdent { - fn prepare(&self, s: &mut dyn ::std::fmt::Write, q: sea_query::Quote) { - s.write_fmt(format_args!("{0}", q.left())).unwrap(); - self.unquoted(s); - s.write_fmt(format_args!("{0}", q.right())).unwrap(); - } - fn unquoted(&self, s: &mut dyn ::std::fmt::Write) { - match self { - Self::Table => s.write_fmt(format_args!("{0}", "todo")).unwrap(), - Self::Id => s.write_fmt(format_args!("{0}", "id")).unwrap(), - Self::Title => s.write_fmt(format_args!("{0}", "title")).unwrap(), - Self::Description => { - s.write_fmt(format_args!("{0}", "description")).unwrap() - } - Self::Status => s.write_fmt(format_args!("{0}", "status")).unwrap(), - Self::CreatedAt => { - s.write_fmt(format_args!("{0}", "created_at")).unwrap() - } - Self::UpdatedAt => { - s.write_fmt(format_args!("{0}", "updated_at")).unwrap() - } - }; - } - } - impl lazybe::Entity for Todo { - type Pk = TodoId; - type Create = CreateTodo; - type Update = UpdateTodo; - type Replace = ReplaceTodo; - fn entity_name() -> &'static str { - "Todo" - } - } - impl lazybe::TableEntity for Todo { - type Row = TodoSqlxRow; - } - impl lazybe::query::GetQuery for Todo { - fn get_query(id: Self::Pk) -> sea_query::SelectStatement { - sea_query::Query::select() - .columns([ - TodoSeaQueryIdent::Id, - TodoSeaQueryIdent::Title, - TodoSeaQueryIdent::Description, - TodoSeaQueryIdent::Status, - TodoSeaQueryIdent::CreatedAt, - TodoSeaQueryIdent::UpdatedAt, - ]) - .from(TodoSeaQueryIdent::Table) - .cond_where( - sea_query::Cond::all() - .add(sea_query::Expr::col(TodoSeaQueryIdent::Id).eq(id)), - ) - .to_owned() - } - } - impl lazybe::query::ListQuery for Todo { - fn list_query( - filter: lazybe::filter::Filter, - ) -> sea_query::SelectStatement { - sea_query::Query::select() - .columns([ - TodoSeaQueryIdent::Id, - TodoSeaQueryIdent::Title, - TodoSeaQueryIdent::Description, - TodoSeaQueryIdent::Status, - TodoSeaQueryIdent::CreatedAt, - TodoSeaQueryIdent::UpdatedAt, - ]) - .from(TodoSeaQueryIdent::Table) - .cond_where(sea_query::Cond::all().add(filter)) - .to_owned() - } - } - impl lazybe::query::CreateQuery for Todo { - fn create_query(input: Self::Create) -> sea_query::InsertStatement { - let now = sqlx::types::chrono::Utc::now(); - sea_query::Query::insert() - .into_table(TodoSeaQueryIdent::Table) - .columns([ - TodoSeaQueryIdent::Id, - TodoSeaQueryIdent::Title, - TodoSeaQueryIdent::Description, - TodoSeaQueryIdent::Status, - TodoSeaQueryIdent::CreatedAt, - TodoSeaQueryIdent::UpdatedAt, - ]) - .values_panic([ - (fourty_two(&input).into()), - input.title.into(), - input.description.into(), - input.status.into(), - now.into(), - now.into(), - ]) - .returning_all() - .to_owned() - } - } - impl lazybe::query::UpdateQuery for Todo { - fn update_query( - id: Self::Pk, - input: Self::Update, - ) -> sea_query::UpdateStatement { - let now = sqlx::types::chrono::Utc::now(); - let mut values = Vec::new(); - if let Some(new_value) = input.title { - values.push((TodoSeaQueryIdent::Title, new_value.into())); - } - if let Some(new_value) = input.description { - values.push((TodoSeaQueryIdent::Description, new_value.into())); - } - if let Some(new_value) = input.status { - values.push((TodoSeaQueryIdent::Status, new_value.into())); - } - values.push((TodoSeaQueryIdent::UpdatedAt, now.into())); - sea_query::Query::update() - .table(TodoSeaQueryIdent::Table) - .values(values) - .cond_where( - sea_query::Cond::all() - .add(sea_query::Expr::col(TodoSeaQueryIdent::Id).eq(id)), - ) - .returning_all() - .to_owned() - } - } - impl lazybe::query::DeleteQuery for Todo { - fn delete_query(id: Self::Pk) -> sea_query::DeleteStatement { - sea_query::Query::delete() - .from_table(TodoSeaQueryIdent::Table) - .cond_where( - sea_query::Cond::all() - .add(sea_query::Expr::col(TodoSeaQueryIdent::Id).eq(id)), - ) - .to_owned() - } - } - impl lazybe::router::Routable for Todo { - fn entity_path() -> &'static str { - "/todos/{id}" - } - fn entity_collection_path() -> &'static str { - "/todos" - } - } - impl lazybe::router::EntityCollectionApi for Todo { - type Resp = Vec; - type Query = (); - fn page_response(page: lazybe::page::Page) -> Self::Resp { - page.data - } - fn page_input(_input: &Self::Query) -> Option { - None - } - fn filter_input(_input: &Self::Query) -> lazybe::filter::Filter { - lazybe::filter::Filter::empty() - } - fn sort_input(_input: &Self::Query) -> lazybe::sort::Sort { - lazybe::sort::Sort::new([TodoSort::id().asc()]) - } - } - impl lazybe::router::ValidationHook for Todo {} - impl utoipa::__dev::ComposeSchema for Todo { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - { - let mut object = utoipa::openapi::ObjectBuilder::new(); - object = object - .property( - "id", - utoipa::openapi::schema::RefBuilder::new() - .ref_location_from_schema_name( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ) - .required("id"); - object = object - .property( - "title", - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ), - ) - .required("title"); - object = object - .property( - "description", - utoipa::openapi::ObjectBuilder::new() - .schema_type({ - use std::iter::FromIterator; - utoipa::openapi::schema::SchemaType::from_iter([ - utoipa::openapi::schema::Type::String, - utoipa::openapi::schema::Type::Null, - ]) - }), - ); - object = object - .property( - "status", - utoipa::openapi::schema::RefBuilder::new() - .ref_location_from_schema_name( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ) - .required("status"); - object = object - .property( - "created_at", - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ) - .format( - Some( - utoipa::openapi::schema::SchemaFormat::KnownFormat( - utoipa::openapi::schema::KnownFormat::DateTime, - ), - ), - ), - ) - .required("created_at"); - object = object - .property( - "updated_at", - utoipa::openapi::ObjectBuilder::new() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ) - .format( - Some( - utoipa::openapi::schema::SchemaFormat::KnownFormat( - utoipa::openapi::schema::KnownFormat::DateTime, - ), - ), - ), - ) - .required("updated_at"); - object - } - .into() - } - } - impl utoipa::ToSchema for Todo { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("Todo") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas - .extend([ - ( - String::from( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ::schema(), - ), - ( - String::from( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!("{0}", ::name()), - ); - res - }), - ), - ::schema(), - ), - ]); - ::schemas(schemas); - ::schemas(schemas); - } - } - pub enum Status { - Todo, - Doing, - Done, - } - #[automatically_derived] - impl ::core::fmt::Debug for Status { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::write_str( - f, - match self { - Status::Todo => "Todo", - Status::Doing => "Doing", - Status::Done => "Done", - }, - ) - } - } - #[automatically_derived] - impl ::core::clone::Clone for Status { - #[inline] - fn clone(&self) -> Status { - match self { - Status::Todo => Status::Todo, - Status::Doing => Status::Doing, - Status::Done => Status::Done, - } - } - } - #[automatically_derived] - impl ::core::marker::StructuralPartialEq for Status {} - #[automatically_derived] - impl ::core::cmp::PartialEq for Status { - #[inline] - fn eq(&self, other: &Status) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr - } - } - #[automatically_derived] - impl ::core::cmp::Eq for Status { - #[inline] - #[doc(hidden)] - #[coverage(off)] - fn assert_receiver_is_total_eq(&self) -> () {} - } - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl _serde::Serialize for Status { - fn serialize<__S>( - &self, - __serializer: __S, - ) -> _serde::__private::Result<__S::Ok, __S::Error> - where - __S: _serde::Serializer, - { - match *self { - Status::Todo => { - _serde::Serializer::serialize_unit_variant( - __serializer, - "Status", - 0u32, - "Todo", - ) - } - Status::Doing => { - _serde::Serializer::serialize_unit_variant( - __serializer, - "Status", - 1u32, - "Doing", - ) - } - Status::Done => { - _serde::Serializer::serialize_unit_variant( - __serializer, - "Status", - 2u32, - "Done", - ) - } - } - } - } - }; - #[doc(hidden)] - #[allow( - non_upper_case_globals, - unused_attributes, - unused_qualifications, - clippy::absolute_paths, - )] - const _: () = { - #[allow(unused_extern_crates, clippy::useless_attribute)] - extern crate serde as _serde; - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for Status { - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - #[doc(hidden)] - enum __Field { - __field0, - __field1, - __field2, - } - #[doc(hidden)] - struct __FieldVisitor; - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "variant identifier", - ) - } - fn visit_u64<__E>( - self, - __value: u64, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::__private::Ok(__Field::__field0), - 1u64 => _serde::__private::Ok(__Field::__field1), - 2u64 => _serde::__private::Ok(__Field::__field2), - _ => { - _serde::__private::Err( - _serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"variant index 0 <= i < 3", - ), - ) - } - } - } - fn visit_str<__E>( - self, - __value: &str, - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - "Todo" => _serde::__private::Ok(__Field::__field0), - "Doing" => _serde::__private::Ok(__Field::__field1), - "Done" => _serde::__private::Ok(__Field::__field2), - _ => { - _serde::__private::Err( - _serde::de::Error::unknown_variant(__value, VARIANTS), - ) - } - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::__private::Result - where - __E: _serde::de::Error, - { - match __value { - b"Todo" => _serde::__private::Ok(__Field::__field0), - b"Doing" => _serde::__private::Ok(__Field::__field1), - b"Done" => _serde::__private::Ok(__Field::__field2), - _ => { - let __value = &_serde::__private::from_utf8_lossy(__value); - _serde::__private::Err( - _serde::de::Error::unknown_variant(__value, VARIANTS), - ) - } - } - } - } - #[automatically_derived] - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>( - __deserializer: __D, - ) -> _serde::__private::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier( - __deserializer, - __FieldVisitor, - ) - } - } - #[doc(hidden)] - struct __Visitor<'de> { - marker: _serde::__private::PhantomData, - lifetime: _serde::__private::PhantomData<&'de ()>, - } - #[automatically_derived] - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = Status; - fn expecting( - &self, - __formatter: &mut _serde::__private::Formatter, - ) -> _serde::__private::fmt::Result { - _serde::__private::Formatter::write_str( - __formatter, - "enum Status", - ) - } - fn visit_enum<__A>( - self, - __data: __A, - ) -> _serde::__private::Result - where - __A: _serde::de::EnumAccess<'de>, - { - match _serde::de::EnumAccess::variant(__data)? { - (__Field::__field0, __variant) => { - _serde::de::VariantAccess::unit_variant(__variant)?; - _serde::__private::Ok(Status::Todo) - } - (__Field::__field1, __variant) => { - _serde::de::VariantAccess::unit_variant(__variant)?; - _serde::__private::Ok(Status::Doing) - } - (__Field::__field2, __variant) => { - _serde::de::VariantAccess::unit_variant(__variant)?; - _serde::__private::Ok(Status::Done) - } - } - } - } - #[doc(hidden)] - const VARIANTS: &'static [&'static str] = &["Todo", "Doing", "Done"]; - _serde::Deserializer::deserialize_enum( - __deserializer, - "Status", - VARIANTS, - __Visitor { - marker: _serde::__private::PhantomData::, - lifetime: _serde::__private::PhantomData, - }, - ) - } - } - }; - impl std::fmt::Display for Status { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let s = match self { - Self::Todo => "Todo".to_string(), - Self::Doing => "Doing".to_string(), - Self::Done => "Done".to_string(), - }; - f.write_fmt(format_args!("{0}", s)) - } - } - impl std::str::FromStr for Status { - type Err = String; - fn from_str(s: &str) -> Result { - let parsed = match s { - "Todo" => Self::Todo, - "Doing" => Self::Doing, - "Done" => Self::Done, - s => { - Err( - ::alloc::__export::must_use({ - let res = ::alloc::fmt::format( - format_args!( - "Cannot parse enum value \'{0}\' to type {1}", - s, - "Status", - ), - ); - res - }), - )? - } - }; - Ok(parsed) - } - } - impl sea_query::Nullable for Status { - fn null() -> sea_query::Value { - sea_query::Value::String(None) - } - } - impl From for sea_query::Value { - fn from(value: Status) -> Self { - sea_query::Value::String(Some(value.to_string().into())) - } - } - impl sqlx::Type for Status - where - Db: sqlx::Database, - String: sqlx::Type, - { - fn type_info() -> ::TypeInfo { - >::type_info() - } - } - impl<'r, Db> sqlx::Decode<'r, Db> for Status - where - Db: sqlx::Database, - for<'s> String: sqlx::Decode<'s, Db>, - { - fn decode( - value: ::ValueRef<'r>, - ) -> Result { - let value_str = >::decode(value)?; - let parsed = ::from_str(&value_str)?; - Ok(parsed) - } - } - impl utoipa::__dev::ComposeSchema for Status { - fn compose( - mut generics: Vec>, - ) -> utoipa::openapi::RefOr { - utoipa::openapi::schema::Object::builder() - .schema_type( - utoipa::openapi::schema::SchemaType::new( - utoipa::openapi::schema::Type::String, - ), - ) - .enum_values::<[&str; 3usize], &str>(Some(["Todo", "Doing", "Done"])) - .into() - } - } - impl utoipa::ToSchema for Status { - fn name() -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed("Status") - } - fn schemas( - schemas: &mut Vec< - (String, utoipa::openapi::RefOr), - >, - ) { - schemas.extend([]); - } - } - fn fourty_two(_: &CreateTodo) -> TodoId { - TodoId(42) - } -}