oku_fs/fs/
mod.rs

1use iroh_blobs::net_protocol::Blobs;
2use iroh_docs::protocol::Docs;
3#[cfg(feature = "fuse")]
4use std::collections::HashMap;
5use std::path::PathBuf;
6#[cfg(feature = "fuse")]
7use std::sync::Arc;
8use std::sync::LazyLock;
9#[cfg(feature = "fuse")]
10use std::sync::RwLock;
11#[cfg(feature = "fuse")]
12use tokio::runtime::Handle;
13use tokio::sync::watch::Sender;
14
15/// Core functionality of an Oku file system.
16pub mod core;
17/// Directory-related functionality of an Oku file system.
18pub mod directory;
19/// File-related functionality of an Oku file system.
20pub mod file;
21/// Implementation of OkuNet.
22pub mod net;
23/// Replica-related functionality of an Oku file system.
24pub mod replica;
25/// Useful functions for implementing the Oku file system.
26pub mod util;
27
28/// The path on disk where the file system is stored.
29pub const FS_PATH: &str = ".oku";
30pub(crate) static NODE_PATH: LazyLock<PathBuf> =
31    LazyLock::new(|| PathBuf::from(FS_PATH).join("node"));
32
33/// An instance of an Oku file system.
34///
35/// The `OkuFs` struct is the primary interface for interacting with an Oku file system.
36#[derive(Clone, Debug)]
37pub struct OkuFs {
38    pub(crate) endpoint: iroh::Endpoint,
39    pub(crate) blobs: Blobs<iroh_blobs::store::fs::Store>,
40    pub(crate) docs: Docs<iroh_blobs::store::fs::Store>,
41    pub(crate) router: iroh::protocol::Router,
42    /// An Iroh node responsible for storing replicas on the local machine, as well as joining swarms to fetch replicas from other nodes.
43    /// A watcher for when replicas are created, deleted, or imported.
44    pub replica_sender: Sender<()>,
45    /// A watcher for whether or not content is being fetched from the OkuNet.
46    pub okunet_fetch_sender: Sender<bool>,
47    #[cfg(feature = "fuse")]
48    /// The handles pointing to paths within the file system; used by FUSE.
49    pub(crate) fs_handles: Arc<RwLock<HashMap<u64, PathBuf>>>,
50    #[cfg(feature = "fuse")]
51    /// The latest file system handle created.
52    pub(crate) newest_handle: Arc<RwLock<u64>>,
53    #[cfg(feature = "fuse")]
54    /// A Tokio runtime handle to perform asynchronous operations with.
55    pub(crate) handle: Handle,
56    pub(crate) dht: mainline::async_dht::AsyncDht,
57}