Skip to main content

dynamo_runtime/
traits.rs

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