Macro pyprotocol
pyprotocol!() { /* proc-macro */ }Expand description
Declares a typing.Protocol for the generated type stubs.
ⓘ
pyo3::pyprotocol! {
/// A binary stream that can be read from and written to
pub SupportsReadWrite {
#[pyo3(signature = (n = -1, /))]
fn read(&self, n: isize) -> Py<PyBytes>;
fn write(&self, data: &[u8]) -> usize;
}
}This defines a unit struct SupportsReadWrite. SupportsReadWrite::TYPE_HINT can be used as
the INPUT_TYPE of a FromPyObject implementation that accepts such objects. Only available
with the experimental-inspect feature. See the type stub section of the guide for details.