@@ -5,6 +5,8 @@ use crate::types::array_compatible;
5
5
use crate :: types:: Type ;
6
6
use crate :: { PgArgumentBuffer , PgHasArrayType , PgTypeInfo , PgValueRef , Postgres } ;
7
7
use std:: borrow:: Cow ;
8
+ use std:: rc:: Rc ;
9
+ use std:: sync:: Arc ;
8
10
9
11
impl Type < Postgres > for str {
10
12
fn type_info ( ) -> PgTypeInfo {
@@ -82,27 +84,6 @@ impl Encode<'_, Postgres> for &'_ str {
82
84
}
83
85
}
84
86
85
- impl Encode < ' _ , Postgres > for Cow < ' _ , str > {
86
- fn encode_by_ref ( & self , buf : & mut PgArgumentBuffer ) -> Result < IsNull , BoxDynError > {
87
- match self {
88
- Cow :: Borrowed ( str) => <& str as Encode < Postgres > >:: encode ( * str, buf) ,
89
- Cow :: Owned ( str) => <& str as Encode < Postgres > >:: encode ( & * * str, buf) ,
90
- }
91
- }
92
- }
93
-
94
- impl Encode < ' _ , Postgres > for Box < str > {
95
- fn encode_by_ref ( & self , buf : & mut PgArgumentBuffer ) -> Result < IsNull , BoxDynError > {
96
- <& str as Encode < Postgres > >:: encode ( & * * self , buf)
97
- }
98
- }
99
-
100
- impl Encode < ' _ , Postgres > for String {
101
- fn encode_by_ref ( & self , buf : & mut PgArgumentBuffer ) -> Result < IsNull , BoxDynError > {
102
- <& str as Encode < Postgres > >:: encode ( & * * self , buf)
103
- }
104
- }
105
-
106
87
impl < ' r > Decode < ' r , Postgres > for & ' r str {
107
88
fn decode ( value : PgValueRef < ' r > ) -> Result < Self , BoxDynError > {
108
89
value. as_str ( )
@@ -114,3 +95,9 @@ impl Decode<'_, Postgres> for String {
114
95
Ok ( value. as_str ( ) ?. to_owned ( ) )
115
96
}
116
97
}
98
+
99
+ forward_encode_impl ! ( Arc <str >, & str , Postgres ) ;
100
+ forward_encode_impl ! ( Rc <str >, & str , Postgres ) ;
101
+ forward_encode_impl ! ( Cow <' _, str >, & str , Postgres ) ;
102
+ forward_encode_impl ! ( Box <str >, & str , Postgres ) ;
103
+ forward_encode_impl ! ( String , & str , Postgres ) ;
0 commit comments