forked from mirrors/kingfisher
updated confluent rule with a checksum. Added zuplo rule with a checksum
This commit is contained in:
parent
1ee9e804b0
commit
c856373fb5
8 changed files with 104 additions and 51 deletions
|
|
@ -109,6 +109,41 @@ impl Filter for ReplaceFilter {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, FilterParameters)]
|
||||
struct LstripCharsArgs {
|
||||
#[parameter(
|
||||
description = "Characters to remove from the start of the input.",
|
||||
arg_type = "str"
|
||||
)]
|
||||
chars: Expression,
|
||||
}
|
||||
|
||||
#[derive(Clone, ParseFilter, FilterReflection, Default)]
|
||||
#[filter(
|
||||
name = "lstrip_chars",
|
||||
description = "Removes the provided characters from the beginning of the string.",
|
||||
parameters(LstripCharsArgs),
|
||||
parsed(LstripCharsFilter)
|
||||
)]
|
||||
pub struct LstripChars;
|
||||
|
||||
#[derive(Debug, FromFilterParameters, Display_filter)]
|
||||
#[name = "lstrip_chars"]
|
||||
struct LstripCharsFilter {
|
||||
#[parameters]
|
||||
args: LstripCharsArgs,
|
||||
}
|
||||
|
||||
impl Filter for LstripCharsFilter {
|
||||
fn evaluate(&self, input: &dyn ValueView, runtime: &dyn Runtime) -> Result<Value> {
|
||||
let args = self.args.evaluate(runtime)?;
|
||||
let chars = args.chars.to_string();
|
||||
let input_str = input.to_kstr();
|
||||
let trimmed = input_str.trim_start_matches(|c| chars.contains(c)).to_string();
|
||||
Ok(Value::scalar(trimmed))
|
||||
}
|
||||
}
|
||||
|
||||
// ── HMAC args ─────────────────────────────────────
|
||||
#[derive(Debug, FilterParameters)]
|
||||
struct HmacArgs {
|
||||
|
|
@ -803,6 +838,7 @@ pub fn register_all(builder: liquid::ParserBuilder) -> liquid::ParserBuilder {
|
|||
.filter(RandomStringFilter::default())
|
||||
.filter(SuffixFilter::default())
|
||||
.filter(PrefixFilter::default())
|
||||
.filter(LstripChars::default())
|
||||
.filter(Crc32Filter::default())
|
||||
.filter(Crc32DecFilter::default())
|
||||
.filter(Crc32HexFilter::default())
|
||||
|
|
@ -1013,6 +1049,16 @@ mod tests {
|
|||
assert_eq!(render(r#"{{ "hello world" | replace: "world", "mars" }}"#), "hello mars");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lstrip_chars_single() {
|
||||
assert_eq!(render(r#"{{ "000abc" | lstrip_chars: "0" }}"#), "abc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lstrip_chars_multiple_chars() {
|
||||
assert_eq!(render(r#"{{ "-=--token" | lstrip_chars: "-=" }}"#), "token");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// iso_timestamp_no_frac filter
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
|||
33
src/main.rs
33
src/main.rs
|
|
@ -5,27 +5,26 @@
|
|||
// * Fallback - system allocator (`system-alloc` feature)
|
||||
// ────────────────────────────────────────────────────────────
|
||||
|
||||
// // --- jemalloc (opt-in) ---
|
||||
// #[cfg(feature = "use-jemalloc")]
|
||||
// #[global_allocator]
|
||||
// static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
// --- jemalloc (opt-in) ---
|
||||
#[cfg(feature = "use-jemalloc")]
|
||||
#[global_allocator]
|
||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
|
||||
// // --- mimalloc (default) ---
|
||||
// #[cfg(all(not(feature = "use-jemalloc"), not(feature = "system-alloc")))]
|
||||
// #[global_allocator]
|
||||
// static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
// --- mimalloc (default) ---
|
||||
#[cfg(all(not(feature = "use-jemalloc"), not(feature = "system-alloc")))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
// // --- system allocator (explicit opt-out) ---
|
||||
// #[cfg(feature = "system-alloc")]
|
||||
// use std::alloc::System;
|
||||
// #[cfg(feature = "system-alloc")]
|
||||
// #[global_allocator]
|
||||
// --- system allocator (explicit opt-out) ---
|
||||
#[cfg(feature = "system-alloc")]
|
||||
use std::alloc::System;
|
||||
#[cfg(feature = "system-alloc")]
|
||||
#[global_allocator]
|
||||
// static GLOBAL: System = System;
|
||||
|
||||
use std::alloc::System;
|
||||
#[global_allocator]
|
||||
static GLOBAL: System = System;
|
||||
|
||||
// use std::alloc::System;
|
||||
// #[global_allocator]
|
||||
// static GLOBAL: System = System;
|
||||
use std::{
|
||||
io::{IsTerminal, Read},
|
||||
sync::{Arc, Mutex},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue