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/Cargo.toml.t | 19 ----- policy/_policies/Cargo.toml.tmpl | 19 +++++ policy/_policies/src/lib.rs.t | 157 --------------------------------------- policy/_policies/src/lib.rs.tmpl | 157 +++++++++++++++++++++++++++++++++++++++ src/bin/butckrepo-refresh.rs | 4 +- 5 files changed, 178 insertions(+), 178 deletions(-) delete mode 100644 policy/_policies/Cargo.toml.t create mode 100644 policy/_policies/Cargo.toml.tmpl delete mode 100644 policy/_policies/src/lib.rs.t create mode 100644 policy/_policies/src/lib.rs.tmpl diff --git a/policy/_policies/Cargo.toml.t b/policy/_policies/Cargo.toml.t deleted file mode 100644 index aab90b9..0000000 --- a/policy/_policies/Cargo.toml.t +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "butck_policies" -version = "0.1.0" -edition = "2024" - -[dependencies] -thiserror = "2" -tokio = { version = "1", features = ["fs"] } - -# Auto generated dependencies -# If you find issues with the dependencies, please -# 1. Delete all code after this comment -# 2. Clear the file `policy/_policies/src/lib.rs` -# 3. Run `cargo run --bin butckrepo-refresh` in the Butchunker root directory ->>>>>>>>>> deps - -@@@ >>> deps -<<>> = { path = "../../<<>>" } -@@@ <<< diff --git a/policy/_policies/Cargo.toml.tmpl b/policy/_policies/Cargo.toml.tmpl new file mode 100644 index 0000000..aab90b9 --- /dev/null +++ b/policy/_policies/Cargo.toml.tmpl @@ -0,0 +1,19 @@ +[package] +name = "butck_policies" +version = "0.1.0" +edition = "2024" + +[dependencies] +thiserror = "2" +tokio = { version = "1", features = ["fs"] } + +# Auto generated dependencies +# If you find issues with the dependencies, please +# 1. Delete all code after this comment +# 2. Clear the file `policy/_policies/src/lib.rs` +# 3. Run `cargo run --bin butckrepo-refresh` in the Butchunker root directory +>>>>>>>>>> deps + +@@@ >>> deps +<<>> = { path = "../../<<>>" } +@@@ <<< 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)<<>> + } +} +@@@ <<< diff --git a/src/bin/butckrepo-refresh.rs b/src/bin/butckrepo-refresh.rs index 2b3d841..ea7e753 100644 --- a/src/bin/butckrepo-refresh.rs +++ b/src/bin/butckrepo-refresh.rs @@ -7,8 +7,8 @@ use std::{ }; use tokio::fs; -const LIB_RS_TEMPLATE_PATH: &str = "policy/_policies/src/lib.rs.t"; -const CARGO_TOML_TEMPLATE_PATH: &str = "policy/_policies/Cargo.toml.t"; +const LIB_RS_TEMPLATE_PATH: &str = "policy/_policies/src/lib.rs.tmpl"; +const CARGO_TOML_TEMPLATE_PATH: &str = "policy/_policies/Cargo.toml.tmpl"; const LIB_RS_PATH: &str = "./policy/_policies/src/lib.rs"; const CARGO_TOML_PATH: &str = "./policy/_policies/Cargo.toml"; -- cgit