pub struct PythonCustomDataWrapper { /* private fields */ }Expand description
Wraps a Python custom data object so it can participate in the Rust data
pipeline as an Arc<dyn CustomDataTrait>.
Holds a reference to the Python object and delegates trait methods via the
Python GIL. ts_event, ts_init, and type_name are cached at construction
to avoid GIL acquisition in the hot path (e.g., data sorting, message routing).
Implementations§
Source§impl PythonCustomDataWrapper
impl PythonCustomDataWrapper
Sourcepub fn new(_py: Python<'_>, py_object: &Bound<'_, PyAny>) -> PyResult<Self>
pub fn new(_py: Python<'_>, py_object: &Bound<'_, PyAny>) -> PyResult<Self>
Creates a new wrapper from a Python custom data object.
Extracts and caches ts_event, ts_init, and the type name from the Python object.
§Errors
Returns an error if required attributes cannot be extracted from the Python object.
Sourcepub fn get_type_name(&self) -> &str
pub fn get_type_name(&self) -> &str
Returns the cached type name.
Trait Implementations§
Source§impl Clone for PythonCustomDataWrapper
Available on crate feature python only.
impl Clone for PythonCustomDataWrapper
Available on crate feature
python only.Source§impl CustomDataTrait for PythonCustomDataWrapper
Available on crate feature python only.
impl CustomDataTrait for PythonCustomDataWrapper
Available on crate feature
python only.Source§fn clone_arc(&self) -> Arc<dyn CustomDataTrait>
fn clone_arc(&self) -> Arc<dyn CustomDataTrait>
Returns a cloned Arc of the custom data.
Source§fn eq_arc(&self, other: &dyn CustomDataTrait) -> bool
fn eq_arc(&self, other: &dyn CustomDataTrait) -> bool
Returns whether the custom data is equal to another.
Source§fn to_pyobject(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
fn to_pyobject(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
Converts the custom data to a Python object. Read more
Source§fn to_json_py(&self) -> Result<String>
fn to_json_py(&self) -> Result<String>
Python-facing JSON serialization. Default implementation forwards to
to_json.
Override if a different behavior is needed for the Python API. Read moreSource§fn type_name_static() -> &'static strwhere
Self: Sized,
fn type_name_static() -> &'static strwhere
Self: Sized,
Returns the type name used in serialized form (e.g. in the
"type" field).Source§impl Debug for PythonCustomDataWrapper
Available on crate feature python only.
impl Debug for PythonCustomDataWrapper
Available on crate feature
python only.Auto Trait Implementations§
impl Freeze for PythonCustomDataWrapper
impl !RefUnwindSafe for PythonCustomDataWrapper
impl Send for PythonCustomDataWrapper
impl Sync for PythonCustomDataWrapper
impl Unpin for PythonCustomDataWrapper
impl UnsafeUnpin for PythonCustomDataWrapper
impl UnwindSafe for PythonCustomDataWrapper
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,
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