diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index e0df43298f..a7193472e0 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -39,6 +39,17 @@ pub struct StreamSlice { } impl StreamSlice { + + /// Create a StreamSlice from a Rust slice. Useful in unit tests. + pub fn from_slice(slice: &[u8], flags: u8, offset: u64) -> Self { + Self { + input: slice.as_ptr() as *const u8, + input_len: slice.len() as u32, + flags, + offset + } + } + pub fn is_gap(&self) -> bool { self.input.is_null() && self.input_len > 0 }