Struct PyPeriod
pub struct PyPeriod {
pub(crate) inner: Period,
}Expand description
A tenor: a signed count of days, weeks, months or years, or the whole term.
Period("3M") or Period(3, "M"). Equality and hashing are by duration
(Period("12M") == Period("1Y")); ordering is by duration where it is
decidable and raises where it is not (1M against 30D); + and -
combine tenors of one unit family (days and weeks, months and years).
Fields§
§inner: PeriodImplementations§
§impl PyPeriod
impl PyPeriod
fn new(
spelling_or_count: &Bound<'_, PyAny>,
unit: Option<&str>,
) -> PyResult<Self>
fn new( spelling_or_count: &Bound<'_, PyAny>, unit: Option<&str>, ) -> PyResult<Self>
A tenor from its spelling ("3M", "-1Y", "2W"), or from a count
and a unit code (3, "M").
fn multiplier(&self) -> i32
fn multiplier(&self) -> i32
The signed count.
fn in_days(&self) -> Option<i32>
fn in_days(&self) -> Option<i32>
The length in days, or None for months, years or the term — none of
which is a fixed number of days.
fn normalize(&self) -> Self
fn normalize(&self) -> Self
The same tenor in the largest unit that states it exactly (12M is
1Y, 14D is 2W).
fn __str__(&self) -> String
fn __repr__(&self) -> String
fn __hash__(&self) -> u64
fn __richcmp__( &self, other: &Bound<'_, PyAny>, op: CompareOp, ) -> PyResult<Py<PyAny>>
fn __add__(&self, other: PyPeriod) -> PyResult<Self>
fn __sub__(&self, other: PyPeriod) -> PyResult<Self>
Trait Implementations§
impl DerefToPyAny for PyPeriod
§impl PyClassImpl for PyPeriod
impl PyClassImpl for PyPeriod
§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
#[pyclass(sequence)]
§type ThreadChecker = SendablePyClass<PyPeriod>
type ThreadChecker = SendablePyClass<PyPeriod>
This handles following two situations: Read more
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
Immutable or mutable
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
§impl PyClassNewTextSignature<PyPeriod> for PyClassImplCollector<PyPeriod>
impl PyClassNewTextSignature<PyPeriod> for PyClassImplCollector<PyPeriod>
fn new_text_signature(self) -> Option<&'static str>
§impl PyMethods<PyPeriod> for PyClassImplCollector<PyPeriod>
impl PyMethods<PyPeriod> for PyClassImplCollector<PyPeriod>
fn py_methods(self) -> &'static PyClassItems
§impl PyTypeInfo for PyPeriod
impl PyTypeInfo for PyPeriod
§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Returns the PyTypeObject instance for this type.
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
Returns the safe abstraction over the type object.
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
Checks if
object is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
Checks if
object is an instance of this type.Auto Trait Implementations§
impl Freeze for PyPeriod
impl RefUnwindSafe for PyPeriod
impl Send for PyPeriod
impl Sync for PyPeriod
impl Unpin for PyPeriod
impl UnsafeUnpin for PyPeriod
impl UnwindSafe for PyPeriod
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