Skip to main content

PluginCustomData

Trait PluginCustomData 

Source
pub trait PluginCustomData:
    'static
    + Send
    + Sync
    + Sized {
    const TYPE_NAME: &'static str;

    // Required methods
    fn ts_event(&self) -> u64;
    fn ts_init(&self) -> u64;
    fn to_json(&self) -> Result<Vec<u8>>;
    fn from_json(payload: &[u8]) -> Result<Self>;
    fn schema_ipc() -> Result<Vec<u8>>;
    fn encode_batch(items: &[&Self]) -> Result<Vec<u8>>;
    fn decode_batch(
        ipc_bytes: &[u8],
        metadata: &[(String, String)],
    ) -> Result<Vec<Self>>;

    // Provided methods
    fn equals(&self, other: &Self) -> bool
       where Self: PartialEq { ... }
    fn clone_value(&self) -> Self
       where Self: Clone { ... }
}
Expand description

Author-facing trait for a custom-data type contributed by a plug-in.

Plug-in authors implement this on their data struct; the nautilus_plugin! macro generates the extern "C" thunks that adapt this trait to a CustomDataVTable.

All trait methods run inside crate::panic::guard in the generated thunks, so a panic surfaces as a PluginError with code PluginErrorCode::Panic instead of unwinding through the FFI.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Canonical type name. Must be unique across a Nautilus deployment.

Required Methods§

Source

fn ts_event(&self) -> u64

Returns the event timestamp as UNIX nanoseconds.

Source

fn ts_init(&self) -> u64

Returns the init timestamp as UNIX nanoseconds.

Source

fn to_json(&self) -> Result<Vec<u8>>

Serializes this value to a JSON payload (no envelope, payload only).

Source

fn from_json(payload: &[u8]) -> Result<Self>

Deserializes a value from a JSON payload (no envelope).

Source

fn schema_ipc() -> Result<Vec<u8>>

Returns the Arrow schema for this type as an Arrow IPC byte stream.

Source

fn encode_batch(items: &[&Self]) -> Result<Vec<u8>>

Encodes a batch of values into an Arrow IPC byte stream.

Source

fn decode_batch( ipc_bytes: &[u8], metadata: &[(String, String)], ) -> Result<Vec<Self>>

Decodes an Arrow IPC byte stream into a vector of values.

Provided Methods§

Source

fn equals(&self, other: &Self) -> bool
where Self: PartialEq,

Tests two values of this type for equality. Default implementation requires PartialEq; override if a custom comparison is needed.

Source

fn clone_value(&self) -> Self
where Self: Clone,

Clones the value into a new heap allocation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§