dynamo_runtime/
traits.rs

1// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4pub mod events;
5
6use super::{DistributedRuntime, Runtime};
7/// A trait for objects that proivde access to the [Runtime]
8pub trait RuntimeProvider {
9    fn rt(&self) -> &Runtime;
10}
11
12/// A trait for objects that provide access to the [DistributedRuntime].
13pub trait DistributedRuntimeProvider {
14    fn drt(&self) -> &DistributedRuntime;
15}
16
17impl RuntimeProvider for DistributedRuntime {
18    fn rt(&self) -> &Runtime {
19        self.runtime()
20    }
21}
22
23// This implementation allows DistributedRuntime to provide access to itself
24// when used in contexts that require DistributedRuntimeProvider.
25// Components, Namespaces, and Endpoints use this trait to access their DRT.
26impl DistributedRuntimeProvider for DistributedRuntime {
27    fn drt(&self) -> &DistributedRuntime {
28        self
29    }
30}