Debian Codegraph @

third_party/rust/sync-guid/src/rusqlite_support.rs

raw
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
5 use crate::Guid;
6 use rusqlite::{
7 self,
8 types::{FromSql, FromSqlResult, ToSql, ToSqlOutput, ValueRef},
9 };
10
11 impl ToSql for Guid {
12 fn to_sql(&self) -> rusqlite::Result<ToSqlOutput<'_>> {
13 Ok(ToSqlOutput::from(self.as_str()))
14 }
15 }
16
17 impl FromSql for Guid {
18 fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
19 value.as_str().map(Guid::from)
20 }
21 }