Skip to content

Commit ed621f4

Browse files
committed
BoxArrayEnc -> BoxedSliceEnc
1 parent 4ec35b4 commit ed621f4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,17 @@ pub trait VecEncodable: CompactEncoding {
265265
}
266266
}
267267

268-
// NB: we DO want &Box<..> because we want the trait to work for boxed things
268+
// NB: we DO want &Box<..> because we want the trait to work for boxed things, hence clippy::allow
269269
#[allow(clippy::borrowed_box)]
270-
/// Define this trait for `T` to get `Box<[T]>: CompactEncoding`
271-
pub trait BoxArrayEncodable: CompactEncoding {
270+
/// Define this trait for `T` to get `impl Box<[T]> for CompactEncoding`
271+
pub trait BoxedSliceEncodable: CompactEncoding {
272272
/// The encoded size in bytes
273-
fn boxed_array_encoded_size(boxed: &Box<[Self]>) -> Result<usize, EncodingError>
273+
fn boxed_slice_encoded_size(boxed: &Box<[Self]>) -> Result<usize, EncodingError>
274274
where
275275
Self: Sized;
276276

277277
/// Encode `Box<[Self]>` to the buffer and return the remainder of the buffer
278-
fn box_encode<'a>(
278+
fn boxed_slice_encode<'a>(
279279
vec: &Box<[Self]>,
280280
buffer: &'a mut [u8],
281281
) -> Result<&'a mut [u8], EncodingError>
@@ -286,7 +286,7 @@ pub trait BoxArrayEncodable: CompactEncoding {
286286
}
287287

288288
/// Decode [`Box<[Self]>`] from buffer
289-
fn box_decode(buffer: &[u8]) -> Result<(Box<[Self]>, &[u8]), EncodingError>
289+
fn boxed_slice_decode(buffer: &[u8]) -> Result<(Box<[Self]>, &[u8]), EncodingError>
290290
where
291291
Self: Sized,
292292
{
@@ -1046,15 +1046,15 @@ impl<const N: usize> VecEncodable for [u8; N] {
10461046
}
10471047
}
10481048

1049-
impl BoxArrayEncodable for u8 {
1050-
fn boxed_array_encoded_size(boxed: &Box<[Self]>) -> Result<usize, EncodingError>
1049+
impl BoxedSliceEncodable for u8 {
1050+
fn boxed_slice_encoded_size(boxed: &Box<[Self]>) -> Result<usize, EncodingError>
10511051
where
10521052
Self: Sized,
10531053
{
10541054
Ok(encoded_size_usize(boxed.len()) + boxed.len())
10551055
}
10561056

1057-
fn box_encode<'a>(
1057+
fn boxed_slice_encode<'a>(
10581058
boxed: &Box<[Self]>,
10591059
buffer: &'a mut [u8],
10601060
) -> Result<&'a mut [u8], EncodingError>
@@ -1065,7 +1065,7 @@ impl BoxArrayEncodable for u8 {
10651065
write_slice(boxed, rest)
10661066
}
10671067

1068-
fn box_decode(buffer: &[u8]) -> Result<(Box<[Self]>, &[u8]), EncodingError>
1068+
fn boxed_slice_decode(buffer: &[u8]) -> Result<(Box<[Self]>, &[u8]), EncodingError>
10691069
where
10701070
Self: Sized,
10711071
{
@@ -1075,20 +1075,20 @@ impl BoxArrayEncodable for u8 {
10751075
}
10761076
}
10771077

1078-
impl<T: BoxArrayEncodable> CompactEncoding for Box<[T]> {
1078+
impl<T: BoxedSliceEncodable> CompactEncoding for Box<[T]> {
10791079
fn encoded_size(&self) -> Result<usize, EncodingError> {
1080-
T::boxed_array_encoded_size(self)
1080+
T::boxed_slice_encoded_size(self)
10811081
}
10821082

10831083
fn encode<'a>(&self, buffer: &'a mut [u8]) -> Result<&'a mut [u8], EncodingError> {
1084-
<T as BoxArrayEncodable>::box_encode(self, buffer)
1084+
<T as BoxedSliceEncodable>::boxed_slice_encode(self, buffer)
10851085
}
10861086

10871087
fn decode(buffer: &[u8]) -> Result<(Self, &[u8]), EncodingError>
10881088
where
10891089
Self: Sized,
10901090
{
1091-
<T as BoxArrayEncodable>::box_decode(buffer)
1091+
<T as BoxedSliceEncodable>::boxed_slice_decode(buffer)
10921092
}
10931093
}
10941094

0 commit comments

Comments
 (0)