summaryrefslogtreecommitdiff
path: root/rola-cli/src/res/bucket.rs
blob: 16b8fc903c8d3fe8bc2ddf544e75a39fe313f989 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::env::current_dir;

use rorolala::bucket::{Bucket, NoProtocol};
use space_system::Space;

/// A resource holding a local filesystem bucket without a protocol.
///
/// This struct wraps a [`Space<Bucket<NoProtocol>>`] that provides access to a
/// local filesystem bucket. It automatically initializes the bucket's current
/// directory from the [`ResCurrentDir`] resource injected into [`ThisProgram`].
#[derive(Clone)]
pub struct ResBucketWithoutProtocol {
    /// The space containing the protocol-less local bucket.
    pub space: Space<Bucket<NoProtocol>>,
}

impl Default for ResBucketWithoutProtocol {
    fn default() -> Self {
        let current_dir = current_dir().unwrap();
        let mut space = Space::new(Bucket::<NoProtocol>::new_local());
        space.set_current_dir(current_dir).unwrap();

        Self { space }
    }
}