bee_block/output/feature/
sender.rs

1// Copyright 2021 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use derive_more::From;
5
6use crate::address::Address;
7
8/// Identifies the validated sender of an output.
9#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, From, packable::Packable)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct SenderFeature(Address);
12
13impl SenderFeature {
14    /// The [`Feature`](crate::output::Feature) kind of a [`SenderFeature`].
15    pub const KIND: u8 = 0;
16
17    /// Creates a new [`SenderFeature`].
18    #[inline(always)]
19    pub fn new(address: Address) -> Self {
20        Self(address)
21    }
22
23    /// Returns the sender [`Address`].
24    #[inline(always)]
25    pub fn address(&self) -> &Address {
26        &self.0
27    }
28}
29
30#[cfg(feature = "dto")]
31#[allow(missing_docs)]
32pub mod dto {
33    use serde::{Deserialize, Serialize};
34
35    use crate::address::dto::AddressDto;
36
37    #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
38    pub struct SenderFeatureDto {
39        #[serde(rename = "type")]
40        pub kind: u8,
41        pub address: AddressDto,
42    }
43}