mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-07-28 14:26:59 -07:00
fix regressions from upgrading dependency in util/src/zerocopy/zerocopy_slice_ext.rs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//! Extension traits for parsing slices into [`zerocopy::Ref`] values using the
|
||||
//! [`RefMaker`] abstraction.
|
||||
|
||||
use zerocopy::{ByteSlice, ByteSliceMut, Ref};
|
||||
use zerocopy::{ByteSlice, ByteSliceMut, Immutable, KnownLayout, Ref, SplitByteSlice};
|
||||
|
||||
use super::RefMaker;
|
||||
|
||||
@@ -52,7 +52,10 @@ pub trait ZerocopySliceExt: Sized + ByteSlice {
|
||||
/// assert_eq!(data_ref.0, 0x0201);
|
||||
/// assert_eq!(data_ref.1, 0x0403);
|
||||
/// ```
|
||||
fn zk_parse<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_parse<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().parse()
|
||||
}
|
||||
|
||||
@@ -80,7 +83,11 @@ pub trait ZerocopySliceExt: Sized + ByteSlice {
|
||||
/// let header_ref = bytes.0.zk_parse_prefix::<Header>().unwrap();
|
||||
/// assert_eq!(header_ref.0, 0xDDCCBBAA);
|
||||
/// ```
|
||||
fn zk_parse_prefix<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_parse_prefix<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
Self: SplitByteSlice,
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().from_prefix()?.parse()
|
||||
}
|
||||
|
||||
@@ -108,7 +115,11 @@ pub trait ZerocopySliceExt: Sized + ByteSlice {
|
||||
/// let header_ref = bytes.0.zk_parse_suffix::<Header>().unwrap();
|
||||
/// assert_eq!(header_ref.0, 0x30201000);
|
||||
/// ```
|
||||
fn zk_parse_suffix<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_parse_suffix<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
Self: SplitByteSlice,
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().from_suffix()?.parse()
|
||||
}
|
||||
}
|
||||
@@ -143,7 +154,10 @@ pub trait ZerocopyMutSliceExt: ZerocopySliceExt + Sized + ByteSliceMut {
|
||||
/// assert_eq!(data_ref.0, [0,0,0,0]);
|
||||
/// assert_eq!(bytes.0, [0, 0, 0, 0]);
|
||||
/// ```
|
||||
fn zk_zeroized<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_zeroized<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().make_zeroized()
|
||||
}
|
||||
|
||||
@@ -171,7 +185,11 @@ pub trait ZerocopyMutSliceExt: ZerocopySliceExt + Sized + ByteSliceMut {
|
||||
/// assert_eq!(data_ref.0, [0,0,0,0]);
|
||||
/// assert_eq!(bytes.0, [0, 0, 0, 0, 0xFF, 0xFF]);
|
||||
/// ```
|
||||
fn zk_zeroized_from_prefix<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_zeroized_from_prefix<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
Self: SplitByteSlice,
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().from_prefix()?.make_zeroized()
|
||||
}
|
||||
|
||||
@@ -199,7 +217,11 @@ pub trait ZerocopyMutSliceExt: ZerocopySliceExt + Sized + ByteSliceMut {
|
||||
/// assert_eq!(data_ref.0, [0,0,0,0]);
|
||||
/// assert_eq!(bytes.0, [0xFF, 0xFF, 0, 0, 0, 0]);
|
||||
/// ```
|
||||
fn zk_zeroized_from_suffix<T>(self) -> anyhow::Result<Ref<Self, T>> {
|
||||
fn zk_zeroized_from_suffix<T>(self) -> anyhow::Result<Ref<Self, T>>
|
||||
where
|
||||
Self: SplitByteSlice,
|
||||
T: KnownLayout + Immutable,
|
||||
{
|
||||
self.zk_ref_maker().from_suffix()?.make_zeroized()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user