# descr.rs - source
Source of the Rust file `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.13.2/src/class/descr.rs`.
Keywords: rust, rustlang, rust-lang

     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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74

    // Copyright (c) 2017-present PyO3 Project and Contributors

    //! Python Description Interface
    //!
    //! [Python information](
    //! https://docs.python.org/3/reference/datamodel.html#implementing-descriptors)

    use crate::callback::IntoPyCallbackOutput;
    use crate::types::PyAny;
    use crate::{FromPyObject, PyClass, PyObject};
    use std::os::raw::c_int;

    /// Descriptor interface
    #[allow(unused_variables)]
    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!()
        }

        fn __delete__(&'p self, instance: &'p PyAny) -> Self::Result
        where
            Self: PyDescrDeleteProtocol<'p>,
        {
            unimplemented!()
        }

        fn __set_name__(&'p self, instance: &'p PyAny) -> Self::Result
        where
            Self: PyDescrSetNameProtocol<'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<()>;
    }

    pub trait PyDescrDeleteProtocol<'p>: PyDescrProtocol<'p> {
        type Inst: FromPyObject<'p>;
        type Result: IntoPyCallbackOutput<()>;
    }

    pub trait PyDescrSetNameProtocol<'p>: PyDescrProtocol<'p> {
        type Inst: FromPyObject<'p>;
        type Result: IntoPyCallbackOutput<()>;
    }

    py_ternarys_func!(descr_get, PyDescrGetProtocol, Self::__get__);
    py_ternarys_func!(descr_set, PyDescrSetProtocol, Self::__set__, c_int);