44use super :: objtype:: PyClassRef ;
55use crate :: function:: { FunctionBox , OptionalArg , OwnedParam , RefParam } ;
66use crate :: pyobject:: {
7- IntoPyObject , PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue , TryFromObject ,
8- TypeProtocol ,
7+ IntoPyObject , PyClassImpl , PyContext , PyObjectRef , PyRef , PyResult , PyValue , ThreadSafe ,
8+ TryFromObject , TypeProtocol ,
99} ;
1010use crate :: slots:: SlotDescriptor ;
1111use crate :: vm:: VirtualMachine ;
1212
13- pub type PyGetterFunc = FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef ) -> PyResult > ;
13+ pub type PyGetterFunc = FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef ) -> PyResult + Send + Sync > ;
1414pub type PySetterFunc =
15- FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef , PyObjectRef ) -> PyResult < ( ) > > ;
15+ FunctionBox < dyn Fn ( & VirtualMachine , PyObjectRef , PyObjectRef ) -> PyResult < ( ) > + Send + Sync > ;
1616
1717pub trait IntoPyGetterFunc < T > {
1818 fn into_getter ( self ) -> PyGetterFunc ;
1919}
2020
2121impl < F , T , R > IntoPyGetterFunc < ( OwnedParam < T > , R , VirtualMachine ) > for F
2222where
23- F : Fn ( T , & VirtualMachine ) -> R + ' static ,
23+ F : Fn ( T , & VirtualMachine ) -> R + ' static + Send + Sync ,
2424 T : TryFromObject ,
2525 R : IntoPyObject ,
2626{
3434
3535impl < F , S , R > IntoPyGetterFunc < ( RefParam < S > , R , VirtualMachine ) > for F
3636where
37- F : Fn ( & S , & VirtualMachine ) -> R + ' static ,
37+ F : Fn ( & S , & VirtualMachine ) -> R + ' static + Send + Sync ,
3838 S : PyValue ,
3939 R : IntoPyObject ,
4040{
4848
4949impl < F , T , R > IntoPyGetterFunc < ( OwnedParam < T > , R ) > for F
5050where
51- F : Fn ( T ) -> R + ' static ,
51+ F : Fn ( T ) -> R + ' static + Send + Sync ,
5252 T : TryFromObject ,
5353 R : IntoPyObject ,
5454{
5959
6060impl < F , S , R > IntoPyGetterFunc < ( RefParam < S > , R ) > for F
6161where
62- F : Fn ( & S ) -> R + ' static ,
62+ F : Fn ( & S ) -> R + ' static + Send + Sync ,
6363 S : PyValue ,
6464 R : IntoPyObject ,
6565{
@@ -90,7 +90,7 @@ pub trait IntoPySetterFunc<T> {
9090
9191impl < F , T , V , R > IntoPySetterFunc < ( OwnedParam < T > , V , R , VirtualMachine ) > for F
9292where
93- F : Fn ( T , V , & VirtualMachine ) -> R + ' static ,
93+ F : Fn ( T , V , & VirtualMachine ) -> R + ' static + Send + Sync ,
9494 T : TryFromObject ,
9595 V : TryFromObject ,
9696 R : IntoPyNoResult ,
@@ -106,7 +106,7 @@ where
106106
107107impl < F , S , V , R > IntoPySetterFunc < ( RefParam < S > , V , R , VirtualMachine ) > for F
108108where
109- F : Fn ( & S , V , & VirtualMachine ) -> R + ' static ,
109+ F : Fn ( & S , V , & VirtualMachine ) -> R + ' static + Send + Sync ,
110110 S : PyValue ,
111111 V : TryFromObject ,
112112 R : IntoPyNoResult ,
@@ -122,7 +122,7 @@ where
122122
123123impl < F , T , V , R > IntoPySetterFunc < ( OwnedParam < T > , V , R ) > for F
124124where
125- F : Fn ( T , V ) -> R + ' static ,
125+ F : Fn ( T , V ) -> R + ' static + Send + Sync ,
126126 T : TryFromObject ,
127127 V : TryFromObject ,
128128 R : IntoPyNoResult ,
@@ -134,7 +134,7 @@ where
134134
135135impl < F , S , V , R > IntoPySetterFunc < ( RefParam < S > , V , R ) > for F
136136where
137- F : Fn ( & S , V ) -> R + ' static ,
137+ F : Fn ( & S , V ) -> R + ' static + Send + Sync ,
138138 S : PyValue ,
139139 V : TryFromObject ,
140140 R : IntoPyNoResult ,
@@ -152,6 +152,8 @@ pub struct PyGetSet {
152152 // doc: Option<String>,
153153}
154154
155+ impl ThreadSafe for PyGetSet { }
156+
155157impl std:: fmt:: Debug for PyGetSet {
156158 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
157159 write ! (
0 commit comments