1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![allow(deprecated)]
use crate::callback::IntoPyCallbackOutput;
use crate::{FromPyObject, PyClass, PyObject};
use std::os::raw::c_int;
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyDescrProtocol<'p>: PyClass {
fn __get__(
slf: Self::Receiver,
instance: Self::Inst,
owner: Option<Self::Owner>,
) -> Self::Result
where
Self: PyDescrGetProtocol<'p>,
{
unimplemented!()
}
fn __set__(slf: Self::Receiver, instance: Self::Inst, value: Self::Value) -> Self::Result
where
Self: PyDescrSetProtocol<'p>,
{
unimplemented!()
}
}
pub trait PyDescrGetProtocol<'p>: PyDescrProtocol<'p> {
type Receiver: crate::derive_utils::TryFromPyCell<'p, Self>;
type Inst: FromPyObject<'p>;
type Owner: FromPyObject<'p>;
type Result: IntoPyCallbackOutput<PyObject>;
}
pub trait PyDescrSetProtocol<'p>: PyDescrProtocol<'p> {
type Receiver: crate::derive_utils::TryFromPyCell<'p, Self>;
type Inst: FromPyObject<'p>;
type Value: FromPyObject<'p>;
type Result: IntoPyCallbackOutput<()>;
}
py_ternarys_func!(descr_get, PyDescrGetProtocol, Self::__get__);
py_ternarys_func!(descr_set, PyDescrSetProtocol, Self::__set__, c_int);