Skip to main content

Cursor

Trait Cursor 

Source
pub trait Cursor {
    type T: Encode + Decode;

    // Required method
    fn serialize(&self) -> Self::T;

    // Provided methods
    fn serialize_cursor(&self) -> Result<Value, CursorError> { ... }
    fn deserialize_cursor(value: &Value) -> Result<Self::T, CursorError> { ... }
}
Expand description

Trait for types that can be used as pagination cursors.

Implementors define how to serialize their position data to/from base64-encoded cursor values.

Required Associated Types§

Source

type T: Encode + Decode

The cursor data type (e.g., EventCursor)

Required Methods§

Source

fn serialize(&self) -> Self::T

Extracts cursor data from this item.

Provided Methods§

Source

fn serialize_cursor(&self) -> Result<Value, CursorError>

Serializes cursor data to a base64 Value.

Source

fn deserialize_cursor(value: &Value) -> Result<Self::T, CursorError>

Deserializes cursor data from a base64 Value.

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.

Implementors§