Skip to main content

harmos_runtime/operations/
context.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19
20// Local Imports
21use super::CallContext;
22use crate::Result;
23
24/* === Constants === */
25
26/* === Macros === */
27
28/* === Type Aliases === */
29
30/* === Structs === */
31
32#[cfg(feature = "grpc")]
33pub(crate) struct Deadline(pub(crate) tokio::time::Instant);
34
35pub struct ContextMut<'a> {
36    context: &'a mut CallContext,
37}
38
39/* === Enums === */
40
41/* === Traits === */
42
43/* === Implementations === */
44
45impl<'a> ContextMut<'a> {
46    pub(crate) fn new(context: &'a mut CallContext) -> Self {
47        Self { context }
48    }
49
50    pub fn insert<T: Send + Sync + 'static>(&mut self, value: T) -> Result<()> {
51        Ok(self.context.insert(value)?)
52    }
53
54    pub fn insert_portable<T: harmos_domain::operations::ContextValue>(&mut self, value: T) -> Result<()> {
55        Ok(self.context.insert_portable(value)?)
56    }
57}
58
59/* === Public Functions === */
60
61/* === Private Functions === */
62
63/* === Tests === */