pub trait PyStubType {
// Required method
fn type_output() -> TypeInfo;
// Provided method
fn type_input() -> TypeInfo { ... }
}Expand description
Annotate Rust types with Python type information for stub file generation.
This trait is used to generate Python stub files (.pyi) from Rust types.
For runtime type alias support, see runtime::PyRuntimeType.
Required Methods§
Sourcefn type_output() -> TypeInfo
fn type_output() -> TypeInfo
The type to be used in the output signature, i.e. return type of the Python function or methods.
Provided Methods§
Sourcefn type_input() -> TypeInfo
fn type_input() -> TypeInfo
The type to be used in the input signature, i.e. the arguments of the Python function or methods.
This defaults to the output type, but can be overridden for types that are not valid input types.
For example, Vec::<T>::type_output returns list[T] while Vec::<T>::type_input returns typing.Sequence[T].
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl PyStubType for &str
impl PyStubType for &str
fn type_output() -> TypeInfo
Source§impl PyStubType for Cow<'_, str>
impl PyStubType for Cow<'_, str>
fn type_output() -> TypeInfo
Source§impl PyStubType for Cow<'_, OsStr>
impl PyStubType for Cow<'_, OsStr>
fn type_output() -> TypeInfo
Source§impl PyStubType for Cow<'_, [u8]>
impl PyStubType for Cow<'_, [u8]>
fn type_output() -> TypeInfo
Source§impl PyStubType for IpAddr
impl PyStubType for IpAddr
fn type_output() -> TypeInfo
Source§impl PyStubType for bool
impl PyStubType for bool
fn type_output() -> TypeInfo
Source§impl PyStubType for char
impl PyStubType for char
fn type_output() -> TypeInfo
Source§impl PyStubType for f32
impl PyStubType for f32
fn type_output() -> TypeInfo
Source§impl PyStubType for f64
impl PyStubType for f64
fn type_output() -> TypeInfo
Source§impl PyStubType for i8
impl PyStubType for i8
fn type_output() -> TypeInfo
Source§impl PyStubType for i16
impl PyStubType for i16
fn type_output() -> TypeInfo
Source§impl PyStubType for i32
impl PyStubType for i32
fn type_output() -> TypeInfo
Source§impl PyStubType for i64
impl PyStubType for i64
fn type_output() -> TypeInfo
Source§impl PyStubType for i128
impl PyStubType for i128
fn type_output() -> TypeInfo
Source§impl PyStubType for isize
impl PyStubType for isize
fn type_output() -> TypeInfo
Source§impl PyStubType for u8
impl PyStubType for u8
fn type_output() -> TypeInfo
Source§impl PyStubType for u16
impl PyStubType for u16
fn type_output() -> TypeInfo
Source§impl PyStubType for u32
impl PyStubType for u32
fn type_output() -> TypeInfo
Source§impl PyStubType for u64
impl PyStubType for u64
fn type_output() -> TypeInfo
Source§impl PyStubType for u128
impl PyStubType for u128
fn type_output() -> TypeInfo
Source§impl PyStubType for ()
impl PyStubType for ()
fn type_output() -> TypeInfo
Source§impl PyStubType for usize
impl PyStubType for usize
fn type_output() -> TypeInfo
Source§impl PyStubType for String
impl PyStubType for String
fn type_output() -> TypeInfo
Source§impl PyStubType for Ipv4Addr
impl PyStubType for Ipv4Addr
fn type_output() -> TypeInfo
Source§impl PyStubType for Ipv6Addr
impl PyStubType for Ipv6Addr
fn type_output() -> TypeInfo
Source§impl PyStubType for Duration
impl PyStubType for Duration
fn type_output() -> TypeInfo
Source§impl PyStubType for OsStr
impl PyStubType for OsStr
fn type_output() -> TypeInfo
Source§impl PyStubType for OsString
impl PyStubType for OsString
fn type_output() -> TypeInfo
Source§impl PyStubType for PathBuf
impl PyStubType for PathBuf
fn type_output() -> TypeInfo
fn type_input() -> TypeInfo
Source§impl PyStubType for SystemTime
impl PyStubType for SystemTime
fn type_output() -> TypeInfo
Source§impl PyStubType for NaiveDate
impl PyStubType for NaiveDate
fn type_output() -> TypeInfo
Source§impl PyStubType for NaiveDateTime
impl PyStubType for NaiveDateTime
fn type_output() -> TypeInfo
Source§impl PyStubType for NaiveTime
impl PyStubType for NaiveTime
fn type_output() -> TypeInfo
Source§impl PyStubType for FixedOffset
impl PyStubType for FixedOffset
fn type_output() -> TypeInfo
Source§impl PyStubType for Utc
impl PyStubType for Utc
fn type_output() -> TypeInfo
Source§impl PyStubType for Uuid
Available on crate feature uuid only.
impl PyStubType for Uuid
Available on crate feature
uuid only.