1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: <text>
// Copyright(c) 2026 Liebherr-Digital Development Center GmbH
// Written by Thomas Witte <thomas.witte@liebherr.com>
// </text>
use Error;
/// An *UpdateTrigger* encapsulates the condition to start an update workflow.
/// If the update is triggered, the trigger provides the update with user
/// defined information, e.g. additional configuration or the triggering event.
///
/// ``` rust
/// use libupdated::traits::update_trigger::*;
/// use libupdated::update_workflow::UpdateError;
/// use std::time::Instant;
///
/// enum TriggerSource {Manual(String), Timed(Instant)}
///
/// async fn example(trigger: &mut impl UpdateTrigger<TriggerSource>) -> Result<(), UpdateError> {
/// match trigger.update_triggered().await? {
/// TriggerSource::Manual(config) => {
/// println!("Manual update triggered. Config: {config}")
/// },
/// TriggerSource::Timed(time) => {
/// println!("Timed update triggered. Time: {time:?}")
/// },
/// }
///
/// Ok(())
/// }
/// ```
// Implement UpdateTrigger for tuples of UpdateTriggers with up to 5 elements
// all trigger conditions are awaited in parallel and the user data of the
// first trigger that fires is returned. All other triggers are cancelled.
impl_update_trigger_for_tuple!
impl_update_trigger_for_tuple!
impl_update_trigger_for_tuple!
impl_update_trigger_for_tuple!