faststr-fork 0.2.21

Faststr is a string library that reduces the cost of clone.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use sqlx::{database::HasValueRef, Database, Decode, Encode};

impl<'r, DB: Database> Decode<'r, DB> for crate::FastStr where String: Decode<'r, DB>{
    fn decode(value: <DB as HasValueRef<'r>>::ValueRef) -> Result<Self, Box<dyn std::error::Error + Send + Sync>> {
        let value = <String as Decode<DB>>::decode(value)?;
        Ok(crate::FastStr::from(value))
    }
}

impl<DB: Database> Encode<DB> for crate::FastStr where String: Encode<DB>{
    fn encode_by_ref(&self) -> <DB as HasValueRef<'_>>::ValueRef {
        self.as_str().encode_by_ref()
    }
}