libdd_profiling/collections/string_table/
error.rs

1// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/
2// SPDX-License-Identifier: Apache-2.0
3
4#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
5pub enum Error {
6    OutOfMemory,
7    StorageFull,
8}
9
10impl core::fmt::Display for Error {
11    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12        let msg = match self {
13            Error::OutOfMemory => "out of memory",
14            Error::StorageFull => "storage full",
15        };
16        std::fmt::Display::fmt(msg, f)
17    }
18}
19
20impl core::error::Error for Error {}
21
22impl From<libdd_alloc::AllocError> for Error {
23    fn from(_: libdd_alloc::AllocError) -> Error {
24        Error::OutOfMemory
25    }
26}
27
28impl From<std::collections::TryReserveError> for Error {
29    fn from(_: std::collections::TryReserveError) -> Error {
30        Error::OutOfMemory
31    }
32}
33
34impl From<indexmap::TryReserveError> for Error {
35    fn from(_: indexmap::TryReserveError) -> Error {
36        Error::OutOfMemory
37    }
38}