Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/content/content_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ where
media_type: MediaType,
) -> Result<UnregisteredTemplate, TemplateError>;

fn get_internal(&self, route: &Route) -> Option<&ContentRepresentations>;

fn get(&self, route: &Route) -> Option<&ContentRepresentations>;

fn handlebars_registry(&self) -> &Handlebars;
}
pub trait InternalContentEngine {
fn get_internal(&self, route: &Route) -> Option<&ContentRepresentations>;
}

/// A [`ContentEngine`](trait.ContentEngine.html) that serves files from a
/// [`ContentDirectory`](struct.ContentDirectory.html).
Expand Down Expand Up @@ -393,15 +394,21 @@ where
self.content_registry.get(route)
}

fn get_internal(&self, route: &Route) -> Option<&ContentRepresentations> {
self.content_registry.get_internal(route)
}

fn handlebars_registry(&self) -> &Handlebars {
&self.handlebars_registry
}
}

impl<'engine, ServerInfo> InternalContentEngine
for FilesystemBasedContentEngine<'engine, ServerInfo>
where
ServerInfo: Clone + Serialize,
{
fn get_internal(&self, route: &Route) -> Option<&ContentRepresentations> {
self.content_registry.get_internal(route)
}
}

#[cfg(test)]
mod tests {
use super::test_lib::*;
Expand Down
3 changes: 2 additions & 1 deletion src/content/handlebars_helpers/get.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::content::content_engine::InternalContentEngine;
use crate::content::*;
use futures::executor;
use futures::stream::TryStreamExt;
Expand Down Expand Up @@ -29,7 +30,7 @@ where
impl<ServerInfo, Engine> handlebars::HelperDef for GetHelper<ServerInfo, Engine>
where
ServerInfo: Clone + Serialize,
Engine: ContentEngine<ServerInfo>,
Engine: ContentEngine<ServerInfo> + InternalContentEngine,
{
fn call<'registry: 'context, 'context>(
&self,
Expand Down
3 changes: 0 additions & 3 deletions src/content/test_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ impl<'a> ContentEngine<()> for MockContentEngine<'a> {
fn get(&self, _: &Route) -> Option<&ContentRepresentations> {
None
}
fn get_internal(&self, _: &Route) -> Option<&ContentRepresentations> {
None
}
fn handlebars_registry(&self) -> &Handlebars {
&self.0
}
Expand Down