Skip to content

Commit

Permalink
Add some more documentation about some function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Jan 22, 2024
1 parent e6db7d7 commit d9a441b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion diesel_derives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ pub fn table_proc(input: TokenStream) -> TokenStream {
///
/// Support for additional types can be added by providing manual implementations of
/// `HasSqlType`, `FromSql` and `ToSql` for the corresponding type, all databases included
/// in your enum, and the backend generated by this derive called MultiBackend.
/// in your enum, and the backend generated by this derive called `MultiBackend`.
/// For example to support `diesel::sql_types::TimestamptzSqlite` with the `time` crate:
/// ```
/// # #[cfg(all(feature = "sqlite", feature = "time"))]
Expand All @@ -1646,20 +1646,26 @@ pub fn table_proc(input: TokenStream) -> TokenStream {
/// Sqlite(diesel::SqliteConnection),
/// }
///
/// // The `MultiBackend` type is generated by `#[derive(diesel::MultiConnection)]`
/// impl HasSqlType<diesel::sql_types::TimestamptzSqlite> for MultiBackend {
/// fn metadata(lookup: &mut Self::MetadataLookup) -> Self::TypeMetadata {
/// // The `lookup_sql_type` function is exposed by the `MultiBackend` type
/// MultiBackend::lookup_sql_type::<diesel::sql_types::TimestamptzSqlite>(lookup)
/// }
/// }
///
/// impl FromSql<diesel::sql_types::TimestamptzSqlite, MultiBackend> for time::OffsetDateTime {
/// fn from_sql(bytes: <MultiBackend as Backend>::RawValue<'_>) -> deserialize::Result<Self> {
/// // The `from_sql` function is exposed by the `RawValue` type of the
/// // `MultiBackend` type
/// bytes.from_sql::<time::OffsetDateTime, diesel::sql_types::TimestamptzSqlite>()
/// }
/// }
///
/// impl ToSql<diesel::sql_types::TimestamptzSqlite, MultiBackend> for time::OffsetDateTime {
/// fn to_sql<'b>(&'b self, out: &mut serialize::Output<'b, '_, MultiBackend>) -> serialize::Result {
/// /// `set_value` expects a tuple consisting of the target SQL type
/// /// and self for `MultiBackend`
/// out.set_value((diesel::sql_types::TimestamptzSqlite, self));
/// Ok(IsNull::No)
/// }
Expand Down

0 comments on commit d9a441b

Please sign in to comment.