From 74e16adb598bd3e52c33018e9021c7535210621e Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Mon, 9 Mar 2026 14:58:43 +0800 Subject: Rename policy template files from .t to .tmpl extension --- policy/_policies/src/lib.rs.t | 157 --------------------------------------- policy/_policies/src/lib.rs.tmpl | 157 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 157 deletions(-) delete mode 100644 policy/_policies/src/lib.rs.t create mode 100644 policy/_policies/src/lib.rs.tmpl (limited to 'policy/_policies/src') diff --git a/policy/_policies/src/lib.rs.t b/policy/_policies/src/lib.rs.t deleted file mode 100644 index db0dc0f..0000000 --- a/policy/_policies/src/lib.rs.t +++ /dev/null @@ -1,157 +0,0 @@ -// Auto generated dependencies -// If you find issues with the dependencies, please -// 1. Delete all code after this comment -// 2. Clear the auto generated part in `policy/_policies/Cargo.toml` -// 3. Run `cargo run --bin butckrepo-refresh` in the Butchunker root directory -pub mod error; -pub mod stream_read; - -use error::ChunkFailed; -use std::{collections::HashMap, path::Path}; - -use crate::stream_read::chunk_stream_process; - -/// Chunks the specified raw data using the specified chunking policy -/// -/// # Parameters -/// - `policy_name`: Chunking policy name, currently supports <<>> policies -/// - `raw_data`: Raw data byte slice -/// - `params`: Hashmap of parameters required by the chunking policy -pub async fn chunk_with( - policy_name: &str, - raw_data: &[u8], - params: &HashMap<&str, &str>, -) -> Result, ChunkFailed> { - match policy_name { ->>>>>>>>>> match_arms - _ => Err(ChunkFailed::PolicyNotFound), - } -} - -pub async fn chunk_stream_with( - policy_name: &str, - size: u32, - path: &Path, - callback: F, - params: &HashMap<&str, &str>, -) -> Result<(), ChunkFailed> -where - F: FnMut(Vec) -> std::pin::Pin> + Send>>, -{ - match policy_name { ->>>>>>>>>> match_arms_stream - _ => Err(ChunkFailed::PolicyNotFound), - } -} - -pub async fn chunk_stream_display_boundaries( - policy_name: &str, - size: u32, - path: &Path, - params: &HashMap<&str, &str>, -) -> Result, ChunkFailed> { - match policy_name { ->>>>>>>>>> match_arms_stream_display - _ => Err(ChunkFailed::PolicyNotFound), - } -} - -pub fn policies() -> Vec<&'static str> { - vec![ ->>>>>>>>>> policy_names - ] -} - -pub fn stream_policies() -> Vec<&'static str> { - vec![ ->>>>>>>>>> stream_policy_names - ] -} - ->>>>>>>>>> exports_simple ->>>>>>>>>> exports_stream ->>>>>>>>>> exports_both - -@@@ >>> match_arms - "<<>>" => Ok(<<>>::chunk(raw_data, params).await), -@@@ <<< - -@@@ >>> match_arms_stream - "<<>>" => { - let mut stream = <<>>::default(); - chunk_stream_process( - path, &mut stream, size, callback, params, - async |current_data, len, stream, params| { - <<>>::chunk_stream(current_data, len, stream, params).await - }, - ) - .await - } -@@@ <<< - -@@@ >>> match_arms_stream_display - "<<>>" => { - let mut stream = <<>>::default(); - crate::stream_read::chunk_stream_display_boundaries( - path, &mut stream, size, params, - async |current_data, len, stream, params| { - <<>>::chunk_stream(current_data, len, stream, params).await - }, - ) - .await - } -@@@ <<< - -@@@ >>> policy_names - // <<>> - "<<>>", -@@@ <<< - -@@@ >>> stream_policy_names - // <<>> - "<<>>", -@@@ <<< - -@@@ >>> exports_simple -pub mod <<>> { - use std::collections::HashMap; - pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec { - <<>>::<<>>(raw_data, params)<<>> - } -} -@@@ <<< - -@@@ >>> exports_stream -pub mod <<>> { - pub use <<>>; - - pub async fn chunk_stream( - current_data: &[u8], - len: u32, - stream: &mut <<>>, - params: &std::collections::HashMap<&str, &str>, - ) -> Option { - <<>>::<<>>(current_data, len, stream, params)<<>> - } -} -@@@ <<< - -@@@ >>> exports_both -pub mod <<>> { - pub use <<>>; - use std::collections::HashMap; - - pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec { - <<>>::<<>>(raw_data, params)<<>> - } - - pub async fn chunk_stream( - current_data: &[u8], - len: u32, - stream: &mut <<>>, - params: &HashMap<&str, &str>, - ) -> Option { - <<>>::<<>>(current_data, len, stream, params)<<>> - } -} -@@@ <<< diff --git a/policy/_policies/src/lib.rs.tmpl b/policy/_policies/src/lib.rs.tmpl new file mode 100644 index 0000000..db0dc0f --- /dev/null +++ b/policy/_policies/src/lib.rs.tmpl @@ -0,0 +1,157 @@ +// Auto generated dependencies +// If you find issues with the dependencies, please +// 1. Delete all code after this comment +// 2. Clear the auto generated part in `policy/_policies/Cargo.toml` +// 3. Run `cargo run --bin butckrepo-refresh` in the Butchunker root directory +pub mod error; +pub mod stream_read; + +use error::ChunkFailed; +use std::{collections::HashMap, path::Path}; + +use crate::stream_read::chunk_stream_process; + +/// Chunks the specified raw data using the specified chunking policy +/// +/// # Parameters +/// - `policy_name`: Chunking policy name, currently supports <<>> policies +/// - `raw_data`: Raw data byte slice +/// - `params`: Hashmap of parameters required by the chunking policy +pub async fn chunk_with( + policy_name: &str, + raw_data: &[u8], + params: &HashMap<&str, &str>, +) -> Result, ChunkFailed> { + match policy_name { +>>>>>>>>>> match_arms + _ => Err(ChunkFailed::PolicyNotFound), + } +} + +pub async fn chunk_stream_with( + policy_name: &str, + size: u32, + path: &Path, + callback: F, + params: &HashMap<&str, &str>, +) -> Result<(), ChunkFailed> +where + F: FnMut(Vec) -> std::pin::Pin> + Send>>, +{ + match policy_name { +>>>>>>>>>> match_arms_stream + _ => Err(ChunkFailed::PolicyNotFound), + } +} + +pub async fn chunk_stream_display_boundaries( + policy_name: &str, + size: u32, + path: &Path, + params: &HashMap<&str, &str>, +) -> Result, ChunkFailed> { + match policy_name { +>>>>>>>>>> match_arms_stream_display + _ => Err(ChunkFailed::PolicyNotFound), + } +} + +pub fn policies() -> Vec<&'static str> { + vec![ +>>>>>>>>>> policy_names + ] +} + +pub fn stream_policies() -> Vec<&'static str> { + vec![ +>>>>>>>>>> stream_policy_names + ] +} + +>>>>>>>>>> exports_simple +>>>>>>>>>> exports_stream +>>>>>>>>>> exports_both + +@@@ >>> match_arms + "<<>>" => Ok(<<>>::chunk(raw_data, params).await), +@@@ <<< + +@@@ >>> match_arms_stream + "<<>>" => { + let mut stream = <<>>::default(); + chunk_stream_process( + path, &mut stream, size, callback, params, + async |current_data, len, stream, params| { + <<>>::chunk_stream(current_data, len, stream, params).await + }, + ) + .await + } +@@@ <<< + +@@@ >>> match_arms_stream_display + "<<>>" => { + let mut stream = <<>>::default(); + crate::stream_read::chunk_stream_display_boundaries( + path, &mut stream, size, params, + async |current_data, len, stream, params| { + <<>>::chunk_stream(current_data, len, stream, params).await + }, + ) + .await + } +@@@ <<< + +@@@ >>> policy_names + // <<>> + "<<>>", +@@@ <<< + +@@@ >>> stream_policy_names + // <<>> + "<<>>", +@@@ <<< + +@@@ >>> exports_simple +pub mod <<>> { + use std::collections::HashMap; + pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec { + <<>>::<<>>(raw_data, params)<<>> + } +} +@@@ <<< + +@@@ >>> exports_stream +pub mod <<>> { + pub use <<>>; + + pub async fn chunk_stream( + current_data: &[u8], + len: u32, + stream: &mut <<>>, + params: &std::collections::HashMap<&str, &str>, + ) -> Option { + <<>>::<<>>(current_data, len, stream, params)<<>> + } +} +@@@ <<< + +@@@ >>> exports_both +pub mod <<>> { + pub use <<>>; + use std::collections::HashMap; + + pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec { + <<>>::<<>>(raw_data, params)<<>> + } + + pub async fn chunk_stream( + current_data: &[u8], + len: u32, + stream: &mut <<>>, + params: &HashMap<&str, &str>, + ) -> Option { + <<>>::<<>>(current_data, len, stream, params)<<>> + } +} +@@@ <<< -- cgit