diff options
Diffstat (limited to 'policy/_policies/src/lib.rs')
| -rw-r--r-- | policy/_policies/src/lib.rs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/policy/_policies/src/lib.rs b/policy/_policies/src/lib.rs index 397579a..f49134d 100644 --- a/policy/_policies/src/lib.rs +++ b/policy/_policies/src/lib.rs @@ -28,16 +28,41 @@ pub async fn chunk_with( } } -pub async fn chunk_stream_with( +pub async fn chunk_stream_with<F>( policy_name: &str, size: u32, path: &Path, + callback: F, params: &HashMap<&str, &str>, -) -> Result<Vec<u32>, ChunkFailed> { +) -> Result<(), ChunkFailed> +where + F: FnMut(Vec<u8>) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<(), std::io::Error>> + Send>>, +{ match policy_name { "butck_fixed_size" => { let mut stream = butck_fixed_size::FixedSizeStream::default(); chunk_stream_process( + path, &mut stream, size, callback, params, + async |current_data, len, stream, params| { + butck_fixed_size::chunk_stream(current_data, len, stream, params).await + }, + ) + .await + } + _ => Err(ChunkFailed::PolicyNotFound), + } +} + +pub async fn chunk_stream_display_boundaries( + policy_name: &str, + size: u32, + path: &Path, + params: &HashMap<&str, &str>, +) -> Result<Vec<u32>, ChunkFailed> { + match policy_name { + "butck_fixed_size" => { + let mut stream = butck_fixed_size::FixedSizeStream::default(); + crate::stream_read::chunk_stream_display_boundaries( path, &mut stream, size, params, async |current_data, len, stream, params| { butck_fixed_size::chunk_stream(current_data, len, stream, params).await @@ -56,6 +81,13 @@ pub fn policies() -> Vec<&'static str> { ] } +pub fn stream_policies() -> Vec<&'static str> { + vec![ + // butck_fixed_size + "butck_fixed_size", + ] +} + pub mod butck_fixed_size { pub use butck_fixed_size::FixedSizeStream; use std::collections::HashMap; |
