summaryrefslogtreecommitdiff
path: root/policy/_policies/src/lib.rs.t
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-04 21:26:04 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-04 21:35:09 +0800
commit22926ce29e3f8e040ec349401aeb6a77f32eae72 (patch)
tree678753ec49a61fb9d3e2d8e869393dec90ea7ef4 /policy/_policies/src/lib.rs.t
Initialize Butchunker project structure and policy system
Diffstat (limited to 'policy/_policies/src/lib.rs.t')
-rw-r--r--policy/_policies/src/lib.rs.t117
1 files changed, 117 insertions, 0 deletions
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 <<<policy_count>>> 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<Vec<u32>, 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<Vec<u32>, 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
+ "<<<crate_name>>>" => Ok(<<<crate_name>>>::chunk(raw_data, params).await),
+@@@ <<<
+
+@@@ >>> match_arms_stream
+ "<<<crate_name>>>" => {
+ let mut stream = <<<stream_struct_id>>>::default();
+ chunk_stream_process(
+ path, &mut stream, size, params,
+ async |current_data, len, stream, params| {
+ <<<crate_name>>>::chunk_stream(current_data, len, stream, params).await
+ },
+ )
+ .await
+ }
+@@@ <<<
+
+@@@ >>> policy_names
+ // <<<name>>>
+ "<<<name>>>",
+@@@ <<<
+
+@@@ >>> exports_simple
+pub mod <<<crate_name>>> {
+ use std::collections::HashMap;
+ pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec<u32> {
+ <<<crate_name>>>::<<<matched_func>>>(raw_data, params)<<<has_await>>>
+ }
+}
+@@@ <<<
+
+@@@ >>> exports_stream
+pub mod <<<crate_name>>> {
+ pub use <<<stream_struct_id>>>;
+
+ pub async fn chunk_stream(
+ current_data: &[u8],
+ len: u32,
+ stream: &mut <<<stream_struct_id>>>,
+ params: &std::collections::HashMap<&str, &str>,
+ ) -> Option<u32> {
+ <<<crate_name>>>::<<<matched_func_stream>>>(current_data, len, stream, params)<<<has_await_stream>>>
+ }
+}
+@@@ <<<
+
+@@@ >>> exports_both
+pub mod <<<crate_name>>> {
+ pub use <<<stream_struct_id>>>;
+ use std::collections::HashMap;
+
+ pub async fn chunk(raw_data: &[u8], params: &HashMap<&str, &str>) -> Vec<u32> {
+ <<<crate_name>>>::<<<matched_func>>>(raw_data, params)<<<has_await>>>
+ }
+
+ pub async fn chunk_stream(
+ current_data: &[u8],
+ len: u32,
+ stream: &mut <<<stream_struct_id>>>,
+ params: &HashMap<&str, &str>,
+ ) -> Option<u32> {
+ <<<crate_name>>>::<<<matched_func_stream>>>(current_data, len, stream, params)<<<has_await_stream>>>
+ }
+}
+@@@ <<<