pub struct Cursor {
pub fields: Vec<(String, Value)>,
}Expand description
A cursor for cursor-based pagination.
Cursors encode the position in a result set as a base64 JSON object. The cursor contains the values of the sort fields for the last item.
§Security Note
Cursors use simple base64 encoding, not encryption. The cursor content is easily decoded by clients. This is intentional - cursors are opaque pagination tokens, not security mechanisms.
Do not include sensitive data in cursor fields. Only include the
values needed for pagination (e.g., id, created_at).
If you need to prevent cursor tampering, validate cursor values against expected ranges or sign cursors server-side.
Fields§
§fields: Vec<(String, Value)>Field values that define the cursor position.
Implementations§
Source§impl Cursor
impl Cursor
Sourcepub fn field(self, name: impl Into<String>, value: impl Into<Value>) -> Self
pub fn field(self, name: impl Into<String>, value: impl Into<Value>) -> Self
Add a field value to the cursor.
Sourcepub fn string(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn string(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a string field.
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encode the cursor to a base64 string.
Note: This uses simple base64, not encryption. See Cursor security note.
Sourcepub fn decode(encoded: &str) -> Result<Self, CursorError>
pub fn decode(encoded: &str) -> Result<Self, CursorError>
Decode a cursor from a base64 string.
Returns an error if the cursor exceeds MAX_CURSOR_SIZE (4KB).