cardano_sdk/cardano/
datum.rs

1//  This Source Code Form is subject to the terms of the Mozilla Public
2//  License, v. 2.0. If a copy of the MPL was not distributed with this
3//  file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5use crate::{Hash, PlutusData};
6use std::fmt;
7
8/// A datum as found in [`Output`](crate::Output).
9#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
10pub enum Datum {
11    Hash(Hash<32>),
12    Inline(PlutusData<'static>),
13}
14
15impl fmt::Display for Datum {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        match self {
18            Datum::Hash(hash) => write!(f, "Hash({})", hash),
19            Datum::Inline(data) => write!(f, "Inline({})", data),
20        }
21    }
22}