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§
Required Methods§
Provided Methods§
Sourcefn serialize_cursor(&self) -> Result<Value, CursorError>
fn serialize_cursor(&self) -> Result<Value, CursorError>
Serializes cursor data to a base64 Value.
Sourcefn deserialize_cursor(value: &Value) -> Result<Self::T, CursorError>
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.