dex_sdk/value.rs
1// Copyright (c) 2026 Super Durable, Inc.
2//
3// Licensed under the Sustainable Use License 1.0.
4// You may not use this file except in compliance with the License.
5// See the LICENSE file in the repository root.
6//
7// SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
8
9use serde::Serialize;
10use serde::de::DeserializeOwned;
11
12/// Marks application values that Dex can serialize as JSON and move across handler boundaries.
13///
14/// The blanket implementation accepts owned, thread-safe Serde values. Keep serialized shapes
15/// backward compatible for running Flows, because persisted Attributes, Channel messages, Step
16/// inputs, and RPC payloads may outlive a deployment.
17pub trait Value: DeserializeOwned + Send + Serialize + Sync + 'static {}
18
19impl<T> Value for T where T: DeserializeOwned + Send + Serialize + Sync + 'static {}
20
21pub(crate) fn short_type_name<T: ?Sized>() -> &'static str {
22 std::any::type_name::<T>()
23 .rsplit("::")
24 .next()
25 .expect("Rust type names are non-empty")
26}