@@ -5,6 +5,8 @@ use crate::types::array_compatible;
55use crate :: types:: Type ;
66use crate :: { PgArgumentBuffer , PgHasArrayType , PgTypeInfo , PgValueRef , Postgres } ;
77use std:: borrow:: Cow ;
8+ use std:: rc:: Rc ;
9+ use std:: sync:: Arc ;
810
911impl Type < Postgres > for str {
1012 fn type_info ( ) -> PgTypeInfo {
@@ -82,27 +84,6 @@ impl Encode<'_, Postgres> for &'_ str {
8284 }
8385}
8486
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-
10687impl < ' r > Decode < ' r , Postgres > for & ' r str {
10788 fn decode ( value : PgValueRef < ' r > ) -> Result < Self , BoxDynError > {
10889 value. as_str ( )
@@ -114,3 +95,9 @@ impl Decode<'_, Postgres> for String {
11495 Ok ( value. as_str ( ) ?. to_owned ( ) )
11596 }
11697}
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