gstreamer: Allow dumping mutable byte slices too

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1598>
This commit is contained in:
Sebastian Dröge 2024-11-21 12:59:44 +02:00 committed by GStreamer Marge Bot
parent 9596ef8338
commit 09e5130e1e

View file

@ -26,6 +26,20 @@ impl<'a> ByteSliceExt for &'a [u8] {
} }
} }
impl<'a> ByteSliceExt for &'a mut [u8] {
fn dump(&self) -> Dump {
self.dump_range(..)
}
fn dump_range(&self, range: impl RangeBounds<usize>) -> Dump {
Dump {
data: self,
start: range.start_bound().cloned(),
end: range.end_bound().cloned(),
}
}
}
pub struct Dump<'a> { pub struct Dump<'a> {
pub(crate) data: &'a [u8], pub(crate) data: &'a [u8],
pub(crate) start: Bound<usize>, pub(crate) start: Bound<usize>,