sync_guid/rusqlite_support.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5use crate::Guid;
6use rusqlite::{
7 self,
8 types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef},
9};
10
11impl ToSql for Guid {
12 fn to_sql(&self) -> rusqlite::Result<ToSqlOutput<'_>> {
13 Ok(ToSqlOutput::from(self.as_str()))
14 }
15}
16
17impl FromSql for Guid {
18 fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
19 value.as_str().map(Guid::from)
20 }
21}