Skip to content

Commit

Permalink
ManagedBufferReadToEnd - cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jul 31, 2024
1 parent 98fc73f commit 6e5b26b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
4 changes: 1 addition & 3 deletions framework/base/src/io/arg_de_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::{
try_execute_then_cast, DecodeError, DecodeErrorHandler, TopDecodeInput, TryStaticCast,
},
types::{
heap::Box, BigInt, BigUint, ManagedBuffer, ManagedBufferNestedDecodeInput,
ManagedBufferReadToEnd, ManagedType,
heap::Box, BigInt, BigUint, ManagedBuffer, ManagedBufferNestedDecodeInput, ManagedType,
},
};

Expand Down Expand Up @@ -127,7 +126,6 @@ where
T::type_eq::<ManagedBuffer<AA>>()
|| T::type_eq::<BigUint<AA>>()
|| T::type_eq::<BigInt<AA>>()
|| T::type_eq::<ManagedBufferReadToEnd<AA>>()
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::codec::{EncodeError, EncodeErrorHandler, NestedEncodeOutput, TryStaticCast};

use crate::{
api::ManagedTypeApi,
types::{BigInt, BigUint, ManagedBuffer, ManagedBufferReadToEnd},
};
use crate::{api::ManagedTypeApi, types::ManagedBuffer};

impl<M: ManagedTypeApi> NestedEncodeOutput for ManagedBuffer<M> {
fn write(&mut self, bytes: &[u8]) {
Expand All @@ -13,9 +10,6 @@ impl<M: ManagedTypeApi> NestedEncodeOutput for ManagedBuffer<M> {
#[inline]
fn supports_specialized_type<T: TryStaticCast>() -> bool {
T::type_eq::<ManagedBuffer<M>>()
|| T::type_eq::<ManagedBufferReadToEnd<M>>()
|| T::type_eq::<BigUint<M>>()
|| T::type_eq::<BigInt<M>>()
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
try_execute_then_cast, DecodeError, DecodeErrorHandler, TopDecodeInput, TryStaticCast,
},
err_msg,
types::{BigInt, BigUint, ManagedBuffer, ManagedBufferReadToEnd},
types::{BigInt, BigUint, ManagedBuffer},
};
use alloc::boxed::Box;

Expand Down Expand Up @@ -78,10 +78,7 @@ where

#[inline]
fn supports_specialized_type<T: TryStaticCast>() -> bool {
T::type_eq::<ManagedBuffer<M>>()
|| T::type_eq::<ManagedBufferReadToEnd<M>>()
|| T::type_eq::<BigUint<M>>()
|| T::type_eq::<BigInt<M>>()
T::type_eq::<ManagedBuffer<M>>() || T::type_eq::<BigUint<M>>() || T::type_eq::<BigInt<M>>()
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::codec::{EncodeError, EncodeErrorHandler, TopEncodeOutput, TryStaticCa

use crate::{
api::ManagedTypeApi,
types::{BigInt, BigUint, ManagedBuffer, ManagedBufferReadToEnd},
types::{BigInt, BigUint, ManagedBuffer},
};

impl<M: ManagedTypeApi> TopEncodeOutput for &mut ManagedBuffer<M> {
Expand All @@ -14,10 +14,7 @@ impl<M: ManagedTypeApi> TopEncodeOutput for &mut ManagedBuffer<M> {

#[inline]
fn supports_specialized_type<T: TryStaticCast>() -> bool {
T::type_eq::<ManagedBuffer<M>>()
|| T::type_eq::<ManagedBufferReadToEnd<M>>()
|| T::type_eq::<BigUint<M>>()
|| T::type_eq::<BigInt<M>>()
T::type_eq::<ManagedBuffer<M>>() || T::type_eq::<BigUint<M>>() || T::type_eq::<BigInt<M>>()
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
hex_util::{byte_to_binary_digits, byte_to_hex_digits},
FormatBuffer, FormatByteReceiver, SCBinary, SCCodec, SCDisplay, SCLowerHex,
},
types::{ManagedBuffer, ManagedBufferReadToEnd},
types::ManagedBuffer,
};

use super::{ManagedBufferBuilderImpl, ManagedBufferImplDefault};
Expand Down Expand Up @@ -107,7 +107,7 @@ where

#[inline]
fn supports_specialized_type<T: TryStaticCast>() -> bool {
T::type_eq::<ManagedBuffer<M>>() || T::type_eq::<ManagedBufferReadToEnd<M>>()
T::type_eq::<ManagedBuffer<M>>()
}

#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<M: ManagedTypeApi> NestedEncode for ManagedBufferReadToEnd<M> {
O: NestedEncodeOutput,
H: EncodeErrorHandler,
{
if O::supports_specialized_type::<Self>() {
if O::supports_specialized_type::<ManagedBuffer<M>>() {
dest.push_specialized((), &self.buffer, h)
} else {
Err(h.handle_error(EncodeError::UNSUPPORTED_OPERATION))
Expand Down

0 comments on commit 6e5b26b

Please sign in to comment.