commit_bridge/domain/
mod.rs1pub mod accept_header;
4pub mod api_version;
5pub mod branch_name;
6pub mod commit_hash;
7pub mod event_type;
8pub mod non_empty_string;
9pub mod repo_url;
10pub mod target_repo;
11
12pub use accept_header::AcceptHeader;
13pub use api_version::ApiVersion;
14pub use branch_name::BranchName;
15pub use commit_hash::CommitHash;
16pub use event_type::EventType;
17pub use non_empty_string::NonEmptyString;
18pub use repo_url::RepoUrl;
19pub use target_repo::TargetRepo;
20
21#[macro_export]
27macro_rules! derive_sqlx_traits {
28 ($t:ty) => {
29 impl sqlx::Type<sqlx::Sqlite> for $t {
30 fn type_info() -> sqlx::sqlite::SqliteTypeInfo {
31 <String as sqlx::Type<sqlx::Sqlite>>::type_info()
32 }
33 }
34 impl<'r> sqlx::Decode<'r, sqlx::Sqlite> for $t {
35 fn decode(
36 value: sqlx::sqlite::SqliteValueRef<'r>,
37 ) -> Result<Self, sqlx::error::BoxDynError> {
38 let s = <String as sqlx::Decode<sqlx::Sqlite>>::decode(value)?;
39 <$t>::try_from(s).map_err(|e| Box::new(e) as sqlx::error::BoxDynError)
40 }
41 }
42 impl sqlx::Encode<'_, sqlx::Sqlite> for $t {
43 fn encode_by_ref(
44 &self,
45 buf: &mut Vec<sqlx::sqlite::SqliteArgumentValue<'_>>,
46 ) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync>> {
47 <String as sqlx::Encode<sqlx::Sqlite>>::encode_by_ref(&self.to_string(), buf)
48 }
49 }
50 };
51}