pub trait CustomDataTrait:
HasTsInit
+ Send
+ Sync
+ Debug {
// Required methods
fn type_name(&self) -> &'static str;
fn as_any(&self) -> &dyn Any;
fn ts_event(&self) -> UnixNanos;
fn to_json(&self) -> Result<String>;
fn clone_arc(&self) -> Arc<dyn CustomDataTrait>;
fn eq_arc(&self, other: &dyn CustomDataTrait) -> bool;
// Provided methods
fn to_json_py(&self) -> Result<String> { ... }
fn to_pyobject(&self, _py: Python<'_>) -> PyResult<Py<PyAny>> { ... }
fn type_name_static() -> &'static str
where Self: Sized { ... }
fn from_json(_value: Value) -> Result<Arc<dyn CustomDataTrait>>
where Self: Sized { ... }
}Expand description
Trait for typed custom data that can be used within the Nautilus domain model.
Required Methods§
Sourcefn clone_arc(&self) -> Arc<dyn CustomDataTrait>
fn clone_arc(&self) -> Arc<dyn CustomDataTrait>
Returns a cloned Arc of the custom data.
Sourcefn eq_arc(&self, other: &dyn CustomDataTrait) -> bool
fn eq_arc(&self, other: &dyn CustomDataTrait) -> bool
Returns whether the custom data is equal to another.
Provided Methods§
Sourcefn 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.
§Errors
Returns an error if JSON serialization fails.
Sourcefn 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).
Implementors§
impl CustomDataTrait for StubCustomData
impl CustomDataTrait for PythonCustomDataWrapper
Available on crate feature
python only.