bit_vfs

    Virtual FS over commits

    git
    vfs
    Download zip
    Author
    Version
    0.48.0
    License
    Apache-2.0
    Last updated
    9 days ago
    Downloads
    116

    pub struct Fs {
    git_dir : String
    base_tree :
    ObjectId

    base_commit :
    ObjectId
    ?
    working : WorkingLayer
    layers : Array[Layer]
    cache : ObjectCache
    config : FsConfig
    cached_db :
    ObjectDb
    ?
    cached_promisor_db :
    PromisorDb
    ?
    lazy_mode : Bool
    }

    Fs::add_layer

    Fs::add_layer_from_commit

    fn Fs::add_layer_from_commit(self : Fs, backing_fs : &
    RepoFileSystem
    , commit_id :
    ObjectId
    , name : String) -> Unit raise
    GitError

    Fs::base_commit

    fn Fs::base_commit(self : Fs) ->
    ObjectId
    ?

    Fs::base_tree

    fn Fs::base_tree(self : Fs) ->
    ObjectId

    Fs::checkout_snapshot

    Fs::clear_layers

    fn Fs::clear_layers(self : Fs) -> Unit

    Fs::collect_files_bfs

    fn Fs::collect_files_bfs(self : Fs, read_fs : &
    RepoFileSystem
    , limit : Int) -> Array[String] raise
    GitError

    Collect files in breadth-first order up to a limit. Useful for progressive preloading.

    Fs::discard_changes

    fn Fs::discard_changes(self : Fs) -> Unit

    Fs::empty

    fn Fs::empty(git_dir : String, config? : FsConfig) -> Fs

    Create an empty Fs (no base tree). Uses config.lazy_load to determine loading strategy (default: lazy).

    Fs::exists_in_base

    fn Fs::exists_in_base(self : Fs, backing_fs : &
    RepoFileSystem
    , path : String) -> Bool

    Check if file exists in base tree (ignoring working layer)

    Fs::from_branch

    fn Fs::from_branch(backing_fs : &
    RepoFileSystem
    , git_dir : String, branch : String, config? : FsConfig) -> Fs raise
    GitError

    Create Fs from a branch name. Uses config.lazy_load to determine loading strategy (default: lazy).

    Fs::from_commit

    fn Fs::from_commit(backing_fs : &
    RepoFileSystem
    , git_dir : String, commit_id :
    ObjectId
    , config? : FsConfig) -> Fs raise
    GitError

    Create Fs from a commit. Uses config.lazy_load to determine loading strategy (default: lazy).

    Fs::from_tree

    fn Fs::from_tree(git_dir : String, tree_id :
    ObjectId
    , config? : FsConfig) -> Fs

    Create Fs from a tree ID. Uses config.lazy_load to determine loading strategy (default: lazy).

    Fs::get_db

    Get or load the ObjectDb (cached for performance). Respects lazy_mode: uses lazy loading when true, eager loading when false.

    Fs::get_deleted_files

    fn Fs::get_deleted_files(self : Fs) -> Array[String]

    Fs::get_pending_fetches

    fn Fs::get_pending_fetches(self : Fs, read_fs : &
    RepoFileSystem
    , limit : Int) -> Array[String] raise
    GitError

    Get list of files that need fetching, in BFS order. Useful for showing progress or prioritizing fetches.

    Fs::get_promisor_db

    Get or load the PromisorDb (cached for performance). Returns None if promisor support is disabled in config.

    Fs::get_promisor_remote

    fn Fs::get_promisor_remote(self : Fs, backing_fs : &
    RepoFileSystem
    ) -> String?

    Get the promisor remote URL if available

    Fs::get_working_files

    fn Fs::get_working_files(self : Fs) -> Array[String]

    Fs::git_dir

    fn Fs::git_dir(self : Fs) -> String

    Fs::has_layer

    fn Fs::has_layer(self : Fs, name : String) -> Bool

    Fs::has_promisor

    fn Fs::has_promisor(self : Fs, backing_fs : &
    RepoFileSystem
    ) -> Bool

    Check if this Fs is backed by a partial clone with promisor remote

    Fs::is_dir

    fn Fs::is_dir(self : Fs, backing_fs : &
    RepoFileSystem
    , path : String) -> Bool

    Fs::is_dirty

    fn Fs::is_dirty(self : Fs) -> Bool

    Fs::is_file

    fn Fs::is_file(self : Fs, backing_fs : &
    RepoFileSystem
    , path : String) -> Bool

    Fs::is_lazy

    fn Fs::is_lazy(self : Fs) -> Bool

    Check if lazy loading is enabled

    Fs::is_promisor_enabled

    fn Fs::is_promisor_enabled(self : Fs) -> Bool

    Check if promisor support is enabled

    Fs::list_layers

    fn Fs::list_layers(self : Fs) -> Array[Layer]

    Fs::list_snapshots

    fn Fs::list_snapshots(self : Fs, backing_fs : &
    RepoFileSystem
    , max_count? : Int) -> Array[Snapshot] raise
    GitError

    Fs::mkdir_p

    fn Fs::mkdir_p(self : Fs, path : String) -> Unit

    Fs::needs_fetch

    fn Fs::needs_fetch(self : Fs, read_fs : &
    RepoFileSystem
    , path : String) -> Bool raise
    GitError

    Check if a file requires fetching from remote

    Fs::prefetch

    async fn Fs::prefetch(self : Fs, read_fs : &
    RepoFileSystem
    , write_fs : &
    FileSystem
    , paths : Array[String]) -> Int raise
    GitError

    Prefetch multiple objects from promisor remote (async). Useful for batch fetching before accessing many files.

    Fs::prefetch_bfs

    async fn Fs::prefetch_bfs(self : Fs, read_fs : &
    RepoFileSystem
    , write_fs : &
    FileSystem
    , limit : Int) -> Int raise
    GitError

    Prefetch files in breadth-first order. Prioritizes shallow files (root level first, then subdirs).

    Fs::prefetch_glob

    async fn Fs::prefetch_glob(self : Fs, read_fs : &
    RepoFileSystem
    , write_fs : &
    FileSystem
    , pattern : String) -> Int raise
    GitError

    Prefetch files matching a glob pattern. Example patterns: ".rs", "src//.mbt", "README.*"

    Fs::read_file

    fn Fs::read_file(self : Fs, backing_fs : &
    RepoFileSystem
    , path : String) -> Bytes raise
    GitError

    Fs::read_file_async

    async fn Fs::read_file_async(self : Fs, read_fs : &
    RepoFileSystem
    , write_fs : &
    FileSystem
    , path : String) -> Bytes raise
    GitError

    Read file content, fetching from remote if not available locally (async). This is the primary method for partial clone repositories.

    Fs::readdir

    fn Fs::readdir(self : Fs, backing_fs : &
    RepoFileSystem
    , path : String) -> Array[String] raise
    GitError

    Fs::remove_dir

    fn Fs::remove_dir(self : Fs, path : String) -> Unit

    Fs::remove_file

    fn Fs::remove_file(self : Fs, path : String) -> Unit

    Fs::remove_layer

    fn Fs::remove_layer(self : Fs, name : String) -> Bool

    Fs::rollback

    fn Fs::rollback(self : Fs) -> Unit

    Fs::snapshot

    fn Fs::snapshot(self : Fs, backing_fs : &
    FileSystem
    , rfs : &
    RepoFileSystem
    , message : String, author : String, timestamp : Int64) -> Snapshot raise
    GitError

    Fs::write_file

    fn Fs::write_file(self : Fs, path : String, content : Bytes) -> Unit

    Fs::write_string

    fn Fs::write_string(self : Fs, path : String, content : String) -> Unit

    FsConfig

    pub struct FsConfig {
    max_cache_bytes : Int
    max_cache_entries : Int
    lazy_load : Bool
    enable_promisor : Bool
    }

    FsConfig::default

    fn FsConfig::default() -> FsConfig

    FsConfig::eager

    fn FsConfig::eager() -> FsConfig

    Create config with eager loading (load all packs upfront)

    FsConfig::local_only

    fn FsConfig::local_only() -> FsConfig

    Create config for local-only access (no network fetches)

    Layer

    pub(all) struct Layer {
    tree_id :
    ObjectId

    commit_id :
    ObjectId
    ?
    name : String
    }

    LruCache

    pub struct LruCache[V] {
    hot : Map[String, V]
    cold : Map[String, V]
    hot_bytes : Int
    cold_bytes : Int
    max_bytes : Int
    size_fn : (V) -> Int
    }

    LruCache::clear

    fn[V] LruCache::clear(self : LruCache[V]) -> Unit

    LruCache::contains

    fn[V] LruCache::contains(self : LruCache[V], key : String) -> Bool

    LruCache::get

    fn[V] LruCache::get(self : LruCache[V], key : String) -> V?

    LruCache::length

    fn[V] LruCache::length(self : LruCache[V]) -> Int

    LruCache::new

    fn[V] LruCache::new(max_bytes : Int, size_fn : (V) -> Int) -> LruCache[V]

    LruCache::remove

    fn[V] LruCache::remove(self : LruCache[V], key : String) -> Unit

    LruCache::set

    fn[V] LruCache::set(self : LruCache[V], key : String, value : V) -> Unit

    LruCache::total_bytes

    fn[V] LruCache::total_bytes(self : LruCache[V]) -> Int

    ObjectCache

    pub(all) struct ObjectCache {
    blob_cache : LruCache[Bytes]
    trees : Map[
    ObjectId
    , Array[
    TreeEntry
    ]]
    path_cache : Map[String,
    ObjectId
    ?]
    }

    ObjectCache::clear

    fn ObjectCache::clear(self : ObjectCache) -> Unit

    ObjectCache::get_blob

    fn ObjectCache::get_blob(self : ObjectCache, path : String) -> Bytes?

    ObjectCache::get_path

    fn ObjectCache::get_path(self : ObjectCache, path : String) ->
    ObjectId
    ??

    ObjectCache::invalidate_path

    fn ObjectCache::invalidate_path(self : ObjectCache, path : String) -> Unit

    ObjectCache::new

    fn ObjectCache::new(max_bytes : Int) -> ObjectCache

    ObjectCache::set_blob

    fn ObjectCache::set_blob(self : ObjectCache, path : String, data : Bytes) -> Unit

    ObjectCache::set_path

    fn ObjectCache::set_path(self : ObjectCache, path : String, id :
    ObjectId
    ?) -> Unit

    ObjectCache::set_tree

    Snapshot

    pub(all) struct Snapshot {
    commit_id :
    ObjectId

    tree_id :
    ObjectId

    message : String
    author : String
    timestamp : Int64
    }

    Snapshot::new

    fn Snapshot::new(commit_id :
    ObjectId
    , tree_id :
    ObjectId
    , message : String, author : String, timestamp : Int64) -> Snapshot

    WorkingLayer

    pub(all) struct WorkingLayer {
    files : Map[String, Bytes]
    deleted : Map[String, Bool]
    dirs : Map[String, Bool]
    dirty : Bool
    }

    WorkingLayer::clear

    fn WorkingLayer::clear(self : WorkingLayer) -> Unit

    WorkingLayer::is_dirty

    fn WorkingLayer::is_dirty(self : WorkingLayer) -> Bool

    WorkingLayer::new

    join_path

    fn join_path(root : String, path : String) -> String

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io