Add FromSql for Box<str>, Rc<str> and Arc<str>

This commit is contained in:
Thom Chiovoloni 2020-01-14 05:18:23 -08:00 committed by Thom Chiovoloni
parent a788d40f10
commit 585797b4d6

View File

@ -166,6 +166,24 @@ impl FromSql for String {
}
}
impl FromSql for Box<str> {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
value.as_str().map(Into::into)
}
}
impl FromSql for std::rc::Rc<str> {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
value.as_str().map(Into::into)
}
}
impl FromSql for std::sync::Arc<str> {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
value.as_str().map(Into::into)
}
}
impl FromSql for Vec<u8> {
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
value.as_blob().map(|b| b.to_vec())