alloy_rpc_types_engine/
cancun.rsuse alloc::vec::Vec;
use alloy_primitives::B256;
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CancunPayloadFields {
pub parent_beacon_block_root: B256,
pub versioned_hashes: Vec<B256>,
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MaybeCancunPayloadFields {
fields: Option<CancunPayloadFields>,
}
impl MaybeCancunPayloadFields {
pub const fn none() -> Self {
Self { fields: None }
}
pub fn into_inner(self) -> Option<CancunPayloadFields> {
self.fields
}
pub fn parent_beacon_block_root(&self) -> Option<B256> {
self.fields.as_ref().map(|fields| fields.parent_beacon_block_root)
}
pub fn versioned_hashes(&self) -> Option<&Vec<B256>> {
self.fields.as_ref().map(|fields| &fields.versioned_hashes)
}
pub const fn as_ref(&self) -> Option<&CancunPayloadFields> {
self.fields.as_ref()
}
}
impl From<CancunPayloadFields> for MaybeCancunPayloadFields {
#[inline]
fn from(fields: CancunPayloadFields) -> Self {
Self { fields: Some(fields) }
}
}
impl From<Option<CancunPayloadFields>> for MaybeCancunPayloadFields {
#[inline]
fn from(fields: Option<CancunPayloadFields>) -> Self {
Self { fields }
}
}