Skip to content

Commit

Permalink
drop unused impls
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Nov 29, 2024
1 parent ae18b1d commit df65e4c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl Config {
reader_ctx: &ConfigReaderContext,
) -> Result<Self> {
let mustache = Mustache::parse(schema);
let schema = mustache.render_strict(reader_ctx);
let schema = mustache.partial_render(reader_ctx);
Self::from_source(source, &schema)
}

Expand Down
11 changes: 1 addition & 10 deletions src/core/http/request_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::core::endpoint::Endpoint;
use crate::core::has_headers::HasHeaders;
use crate::core::helpers::headers::MustacheHeaders;
use crate::core::ir::model::{CacheKey, IoId};
use crate::core::mustache::{Eval, EvalStrict, Mustache, Segment};
use crate::core::mustache::{Eval, Mustache, Segment};
use crate::core::path::{PathString, PathValue, ValueString};

/// RequestTemplate is an extension of a Mustache template.
Expand Down Expand Up @@ -302,15 +302,6 @@ impl<'a, A: PathValue> Eval<'a> for ValueStringEval<A> {
}
}

impl<'a, A: PathValue> EvalStrict<'a> for ValueStringEval<A> {
type In = A;
type Out = Option<ValueString<'a>>;

fn eval_strict(&'a self, mustache: &'a Mustache, in_value: &'a Self::In) -> Self::Out {
self.eval(mustache, in_value)
}
}

#[cfg(test)]
mod tests {
use std::borrow::Cow;
Expand Down
41 changes: 13 additions & 28 deletions src/core/mustache/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ impl<'a, A: Path + 'a> Eval<'a> for PathEval<&'a A> {
}
}

impl<'a, A: Path + 'a> EvalStrict<'a> for PathEval<&'a A> {
type In = &'a A;
type Out = Vec<Exit<'a, A>>;

fn eval_strict(&'a self, mustache: &'a Mustache, in_value: &'a Self::In) -> Self::Out {
self.eval(mustache, in_value)
}
}

pub struct PathGraphqlEval<A>(std::marker::PhantomData<A>);

impl<A> PathGraphqlEval<A> {
Expand All @@ -131,33 +122,27 @@ impl<A: PathGraphql> Eval<'_> for PathGraphqlEval<A> {
}
}

impl<A: PathGraphql> EvalStrict<'_> for PathGraphqlEval<A> {
type In = A;
type Out = String;
impl Mustache {
// TODO: drop these methods and directly use the eval implementations
pub fn render(&self, value: &impl PathString) -> String {
PathStringEval::new().eval(self, value)
}

Check warning on line 129 in src/core/mustache/eval.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/mustache/eval.rs

fn eval_strict(&'_ self, mustache: &'_ Mustache, in_value: &'_ Self::In) -> Self::Out {
mustache
pub fn partial_render(&self, value: &impl PathString) -> String {
self
.segments()
.iter()
.map(|segment| match segment {
Segment::Literal(text) => text.to_string(),
Segment::Expression(parts) => in_value.path_graphql(parts).unwrap_or(
Mustache::from(vec![Segment::Expression(parts.to_vec())]).to_string(),
),
Segment::Expression(parts) => value

Check warning on line 137 in src/core/mustache/eval.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/mustache/eval.rs
.path_string(parts)
.map(|v| v.to_string())
.unwrap_or(
Mustache::from(vec![Segment::Expression(parts.to_vec())]).to_string(),
),
})
.collect()
}
}

impl Mustache {
// TODO: drop these methods and directly use the eval implementations
pub fn render(&self, value: &impl PathString) -> String {
PathStringEval::new().eval(self, value)
}

pub fn render_strict(&self, value: &impl PathString) -> String {
PathStringEval::new().eval_strict(self, value)
}

pub fn render_graphql(&self, value: &impl PathGraphql) -> String {
PathGraphqlEval::new().eval(self, value)
Expand Down

0 comments on commit df65e4c

Please sign in to comment.