Skip to main content

dynamo_kv_hashing/
error.rs

1// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Error types for [`crate`].
5
6use dynamo_tokens::{MmInfoError, TokenBlockError};
7
8/// Errors raised while constructing a [`crate::Request`] or computing block hashes.
9#[derive(Debug, thiserror::Error)]
10pub enum KvHashingError {
11    /// Multimodal info validation failed.
12    #[error(transparent)]
13    MmInfo(#[from] MmInfoError),
14
15    /// An error originating from [`dynamo_tokens`] block formation.
16    #[error(transparent)]
17    TokenBlock(#[from] TokenBlockError),
18
19    /// Salt payload could not be canonicalized for hashing.
20    ///
21    /// In practice this is unreachable for the field types we serialize, but the path is
22    /// preserved so the public API never panics on serialization.
23    #[error("failed to canonicalize salt payload: {0}")]
24    SaltSerialization(#[from] serde_json::Error),
25
26    /// A required field was not set on the [`crate::RequestBuilder`].
27    #[error("RequestBuilder missing required field: {0}")]
28    MissingField(&'static str),
29}