ferroui_hot_patch/registration.rs
1use std::collections::BTreeSet;
2
3/// A stable application declaration, supplied when its patch supervisor starts.
4/// Changing registrations is a build-input change and requires process replacement.
5#[derive(Clone, Debug)]
6pub struct FunctionRegistration {
7 pub(crate) source: String,
8 pub(crate) function: String,
9 pub(crate) views: Option<BTreeSet<String>>,
10}
11impl FunctionRegistration {
12 /// A handler or command whose updated body takes effect on its next invocation.
13 /// Register the function here and invoke it through a patch-aware callback helper.
14 pub fn callback(source: impl Into<String>, function: impl Into<String>) -> Self {
15 Self {
16 source: source.into(),
17 function: function.into(),
18 views: None,
19 }
20 }
21
22 /// A synchronous builder which explicitly requests reapplication of these views.
23 /// View identifiers belong to the application; the view transaction must resolve
24 /// them to reversible adapters. At least one nonempty identifier is required.
25 pub fn view_builder(
26 source: impl Into<String>,
27 function: impl Into<String>,
28 views: impl IntoIterator<Item = String>,
29 ) -> Self {
30 Self {
31 source: source.into(),
32 function: function.into(),
33 views: Some(views.into_iter().collect()),
34 }
35 }
36}