pub struct TypeInfo {
pub name: String,
pub import: HashSet<ModuleRef>,
}
Expand description
Type information for creating Python stub files annotated by PyStubType trait.
Fields§
§name: String
The Python type name.
import: HashSet<ModuleRef>
Python modules must be imported in the stub file.
For example, when name
is typing.Sequence[int]
, import
should contain typing
.
This makes it possible to use user-defined types in the stub file.
Implementations§
Source§impl TypeInfo
impl TypeInfo
Sourcepub fn list_of<T: PyStubType>() -> Self
pub fn list_of<T: PyStubType>() -> Self
A list[Type]
type annotation.
Sourcepub fn set_of<T: PyStubType>() -> Self
pub fn set_of<T: PyStubType>() -> Self
A set[Type]
type annotation.
Sourcepub fn dict_of<K: PyStubType, V: PyStubType>() -> Self
pub fn dict_of<K: PyStubType, V: PyStubType>() -> Self
A dict[Type]
type annotation.
Sourcepub fn builtin(name: &str) -> Self
pub fn builtin(name: &str) -> Self
A type annotation of a built-in type provided from builtins
module, such as int
, str
, or float
. Generic builtin types are also possible, such as dict[str, str]
.
Sourcepub fn unqualified(name: &str) -> Self
pub fn unqualified(name: &str) -> Self
Unqualified type.
Sourcepub fn with_module(name: &str, module: ModuleRef) -> Self
pub fn with_module(name: &str, module: ModuleRef) -> Self
A type annotation of a type that must be imported. The type name must be qualified with the module name:
pyo3_stub_gen::TypeInfo::with_module("pathlib.Path", "pathlib".into());
Trait Implementations§
impl Eq for TypeInfo
impl StructuralPartialEq for TypeInfo
Auto Trait Implementations§
impl Freeze for TypeInfo
impl RefUnwindSafe for TypeInfo
impl Send for TypeInfo
impl Sync for TypeInfo
impl Unpin for TypeInfo
impl UnwindSafe for TypeInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more