gstreamer: Allow dumping mutable byte slices too

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1596>
This commit is contained in:
Sebastian Dröge 2024-11-21 12:59:44 +02:00
parent 9c386085e3
commit 5b652aa3d0

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(crate) data: &'a [u8],
pub(crate) start: Bound<usize>,