Skip to main content

compmd_host/
no_store.rs

1//! No pack store: a host that serves its bundle's packs alone.
2
3use compmd_pack::{PackName, Place};
4
5use crate::store::Store;
6use crate::stored_release::StoredRelease;
7
8/// No store: the host serves the bundle's packs alone.
9#[derive(Clone, Copy, Debug, Default)]
10pub struct NoStore;
11
12impl Store for NoStore {
13    fn releases(&self, _pack: &PackName) -> Vec<StoredRelease> {
14        Vec::new()
15    }
16
17    fn file(&self, _place: &Place) -> Option<Vec<u8>> {
18        None
19    }
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn no_store_holds_nothing() {
28        assert_eq!(
29            NoStore.releases(&"@kit/mermaid".parse().expect("a name")),
30            []
31        );
32        assert_eq!(
33            NoStore.file(&"@kit/mermaid@1.0.0/a.js".parse().expect("a place")),
34            None
35        );
36    }
37}