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