Skip to content

Commit

Permalink
failed attempt at clone less caching: argh rust
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 8, 2024
1 parent 9bd1cb0 commit d4ada46
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion v0.5/fastn-package/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl fastn_continuation::Continuation for State {

fn continue_after(
self,
_n: Vec<(String, Option<fastn_section::Document>)>,
_n: Vec<(String, &Option<fastn_section::Document>)>,
) -> fastn_continuation::Result<Self> {
todo!()
}
Expand Down
8 changes: 0 additions & 8 deletions v0.5/fastn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,3 @@ pub enum OutputRequested {
UI,
Data,
}

pub fn full_filler(_i: Vec<String>) -> Vec<(String, Option<fastn_section::Document>)> {
todo!()
}

pub async fn full_filler_async(_i: Vec<String>) -> Vec<(String, Option<fastn_section::Document>)> {
todo!()
}
18 changes: 13 additions & 5 deletions v0.5/fastn/src/section_provider.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#[derive(Default)]
pub struct SectionProvider {}
pub struct SectionProvider {
cache: std::collections::HashMap<String, Option<fastn_section::Document>>,
}

#[async_trait::async_trait]
impl fastn_continuation::AsyncMutProvider for &SectionProvider {
impl<'a> fastn_continuation::AsyncMutProvider for &'a SectionProvider {
type Needed = Vec<String>;
type Found = Vec<(String, Option<fastn_section::Document>)>;
type Found = Vec<(String, &'a Option<fastn_section::Document>)>;

async fn provide(&mut self, _needed: Vec<String>) -> Self::Found {
todo!()
async fn provide(&mut self, needed: Vec<String>) -> Self::Found {
let mut r = vec![];
for f in needed {
if let Some(doc) = self.cache.get(&f) {
r.push((f, doc));
}
}
r
}
}

0 comments on commit d4ada46

Please sign in to comment.