Skip to main content

bee_ledger_types/
consumed_output.rs

1// Copyright 2020-2021 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use bee_block::payload::{milestone::MilestoneIndex, transaction::TransactionId};
5
6/// Represents a newly consumed output.
7#[derive(Clone, Debug, Eq, PartialEq, packable::Packable)]
8pub struct ConsumedOutput {
9    target: TransactionId,
10    milestone_index: MilestoneIndex,
11    milestone_timestamp: u32,
12}
13
14impl ConsumedOutput {
15    /// Creates a new [`ConsumedOutput`].
16    pub fn new(target: TransactionId, milestone_index: MilestoneIndex, milestone_timestamp: u32) -> Self {
17        Self {
18            target,
19            milestone_index,
20            milestone_timestamp,
21        }
22    }
23
24    /// Returns the target transaction of the [`ConsumedOutput`].
25    pub fn target(&self) -> &TransactionId {
26        &self.target
27    }
28
29    /// Returns the milestone index of the [`ConsumedOutput`].
30    pub fn milestone_index(&self) -> MilestoneIndex {
31        self.milestone_index
32    }
33
34    /// Returns the milestone timestamp of the [`ConsumedOutput`].
35    pub fn milestone_timestamp(&self) -> u32 {
36        self.milestone_timestamp
37    }
38}