Trait Encodable

Source
pub trait Encodable {
    // Required method
    fn encode(&self, out: &mut dyn BufMut);

    // Provided method
    fn length(&self) -> usize { ... }
}
Available on crate feature rlp only.
Expand description

A type that can be encoded via RLP.

Required Methods§

Source

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.

Provided Methods§

Source

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes.

The default implementation computes this by encoding the type. When possible, we recommender implementers override this with a specialized implementation.

Implementations on Foreign Types§

Source§

impl Encodable for IpAddr

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for bool

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for str

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for u8

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for u16

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for u32

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for u64

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for u128

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for usize

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for String

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for PhantomPinned

Source§

fn length(&self) -> usize

Source§

fn encode(&self, _out: &mut dyn BufMut)

Source§

impl Encodable for Ipv4Addr

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for Ipv6Addr

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl Encodable for [u8]

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for Cow<'_, T>
where T: ToOwned + Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for &T
where T: Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for &mut T
where T: Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for Box<T>
where T: Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for Rc<T>
where T: Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for Arc<T>
where T: Encodable + ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for Vec<T>
where T: Encodable,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Source§

impl<T> Encodable for PhantomData<T>
where T: ?Sized,

Source§

fn length(&self) -> usize

Source§

fn encode(&self, _out: &mut dyn BufMut)

Source§

impl<const N: usize> Encodable for [u8; N]

Source§

fn length(&self) -> usize

Source§

fn encode(&self, out: &mut dyn BufMut)

Implementors§

Source§

impl Encodable for Parity

Source§

impl Encodable for TxKind

Source§

impl Encodable for Address

Source§

impl Encodable for Bloom

Source§

impl Encodable for alloy_core::primitives::Bytes

Source§

impl Encodable for Function

Source§

impl Encodable for Log

Source§

impl Encodable for Signature

Source§

impl Encodable for alloy_core::rlp::Bytes

Source§

impl Encodable for BytesMut

Source§

impl<T> Encodable for Log<T>
where &'a T: for<'a> Into<LogData>,

Source§

impl<const BITS: usize, const LIMBS: usize> Encodable for Uint<BITS, LIMBS>

Allows a Uint to be serialized as RLP.

Source§

impl<const N: usize> Encodable for FixedBytes<N>