From 22926ce29e3f8e040ec349401aeb6a77f32eae72 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 4 Mar 2026 21:26:04 +0800 Subject: Initialize Butchunker project structure and policy system --- policy/_policies/src/lib.rs.t | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 policy/_policies/src/lib.rs.t (limited to 'policy/_policies/src/lib.rs.t') diff --git a/policy/_policies/src/lib.rs.t b/policy/_policies/src/lib.rs.t new file mode 100644 index 0000000..873a4cd --- /dev/null +++ b/policy/_policies/src/lib.rs.t @@ -0,0 +1,117 @@ +// 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, + params: &HashMap<&str, &str>, +) -> Result, ChunkFailed> { + match policy_name { +>>>>>>>>>> match_arms_stream + _ => Err(ChunkFailed::PolicyNotFound), + } +} + +pub fn policies() -> Vec<&'static str> { + vec![ +>>>>>>>>>> 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, params, + async |current_data, len, stream, params| { + <<>>::chunk_stream(current_data, len, stream, params).await + }, + ) + .await + } +@@@ <<< + +@@@ >>> 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