vyre-spec 0.1.1

Frozen data contracts for vyre — OpSpec, AlgebraicLaw, Category, IntrinsicTable
Documentation
//! Frozen operation type signatures used by validators and catalogs.

use crate::data_type::DataType;

/// Type signature for a vyre IR operation in the frozen data contract.
///
/// Example: an addition operation can declare two `DataType::U32` inputs and
/// one `DataType::U32` output.
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize)]
pub struct OpSignature {
    /// Input parameter types.
    pub inputs: Vec<DataType>,
    /// Output type.
    pub output: DataType,
}

impl OpSignature {
    /// Minimum valid input byte count for this signature.
    #[must_use]
    pub fn min_input_bytes(&self) -> usize {
        self.inputs.iter().map(|dt| dt.min_bytes()).sum()
    }
}