pub trait PyStructSequenceData: Sized {
const REQUIRED_FIELD_NAMES: &'static [&'static str];
const OPTIONAL_FIELD_NAMES: &'static [&'static str];
const UNNAMED_FIELDS_LEN: usize = 0;
// Required method
fn into_tuple(self, vm: &VirtualMachine) -> PyTuple;
// Provided method
fn try_from_elements(
_elements: Vec<PyObjectRef>,
vm: &VirtualMachine,
) -> PyResult<Self> { ... }
}Expand description
Trait for Data structs that back a PyStructSequence.
This trait is implemented by #[pystruct_sequence_data] on the Data struct.
It provides field information, tuple conversion, and element parsing.
Required Associated Constants§
Sourceconst REQUIRED_FIELD_NAMES: &'static [&'static str]
const REQUIRED_FIELD_NAMES: &'static [&'static str]
Names of required fields (in order). Shown in repr.
Sourceconst OPTIONAL_FIELD_NAMES: &'static [&'static str]
const OPTIONAL_FIELD_NAMES: &'static [&'static str]
Names of optional/skipped fields (in order, after required fields).
Provided Associated Constants§
Sourceconst UNNAMED_FIELDS_LEN: usize = 0
const UNNAMED_FIELDS_LEN: usize = 0
Number of unnamed fields (visible but index-only access).
Required Methods§
Sourcefn into_tuple(self, vm: &VirtualMachine) -> PyTuple
fn into_tuple(self, vm: &VirtualMachine) -> PyTuple
Convert this Data struct into a PyTuple.
Provided Methods§
Sourcefn try_from_elements(
_elements: Vec<PyObjectRef>,
vm: &VirtualMachine,
) -> PyResult<Self>
fn try_from_elements( _elements: Vec<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<Self>
Construct this Data struct from tuple elements.
Default implementation returns an error.
Override with #[pystruct_sequence_data(try_from_object)] to enable.
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.