Skip to main content

switchyard_libsy/core/
outcome_metadata.rs

1// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Metadata describing a routing outcome.
5
6/// Identity and optional algorithm evidence attached to a successful routing outcome.
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct OutcomeMetadata {
9    outcome_id: String,
10    /// Stable name of the algorithm that produced the outcome.
11    pub algorithm: String,
12    /// Optional bounded, machine-readable evidence produced by the algorithm.
13    pub evidence: Option<String>,
14}
15
16impl OutcomeMetadata {
17    /// Creates outcome metadata with a new UUIDv7 identifier.
18    pub fn new(algorithm: String, evidence: Option<String>) -> Self {
19        Self {
20            outcome_id: uuid::Uuid::now_v7().to_string(),
21            algorithm,
22            evidence,
23        }
24    }
25
26    /// Returns the unique identifier for this outcome.
27    pub fn outcome_id(&self) -> &str {
28        &self.outcome_id
29    }
30}