Skip to main content

sui_tool/db_shell/
backend.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::db_shell::vfs::VfsPath;
5
6pub struct DirEntry {
7    pub name: String,
8    pub is_dir: bool,
9}
10
11pub trait Backend: Send + Sync {
12    /// List the children of `path` (normal directory listing).
13    fn ls_children(&self, path: &VfsPath, limit: usize) -> anyhow::Result<Vec<DirEntry>>;
14
15    /// List starting from `path` as a cursor into the parent namespace.
16    /// Used for `ls /checkpoints/seq/1234` which means "list 30 from seq 1234".
17    fn ls_cursor(&self, path: &VfsPath, limit: usize) -> anyhow::Result<Vec<DirEntry>>;
18
19    /// Return the JSON representation of the entity at `path`.
20    fn read_json(&self, path: &VfsPath) -> anyhow::Result<serde_json::Value>;
21
22    /// Return the Rust `{:#?}` debug representation of the entity at `path`.
23    fn read_debug(&self, path: &VfsPath) -> anyhow::Result<String>;
24
25    /// Return the raw BCS bytes of the entity at `path`.
26    fn read_bcs(&self, path: &VfsPath) -> anyhow::Result<Vec<u8>>;
27
28    /// Delete the entity at `path`. Destructive and permanent.
29    fn delete(&self, path: &VfsPath) -> anyhow::Result<()>;
30}