34 std::string &,
bool &);
36 std::shared_ptr<void>, std::function<
void(
RowId)>,
40 std::shared_ptr<void>, std::function<
void(
RowId)>);
41 static std::expected<std::optional<ModelRow<SearchItem>>,
ManagedError>
47 static std::expected<std::optional<std::uint64_t>,
ManagedError>
52 std::function<std::expected<void, ManagedError>()>);
54 static std::expected<void, ManagedError> claimChoicePopup(
ManagedScene &, std::shared_ptr<SceneActivity>);
57 static void requestChoicePopup(
ManagedScene &scene, std::shared_ptr<SceneActivity> activity) {
58 scene.choiceIntent_ = std::move(activity);
61 static void cancelChoicePopup(
ManagedScene &scene,
const SceneActivity *activity) {
62 if (
auto pending = scene.choiceIntent_.lock(); pending.get() == activity) {
63 scene.choiceIntent_.reset();
68 auto source = model.lock();
72 std::erase(scene.models_, *source);
79 static std::shared_ptr<portals::detail::ManagedOrigin>
80 exchangeModelOrigin(
ManagedScene &scene, std::shared_ptr<portals::detail::ManagedOrigin> origin) {
81 return std::exchange(scene.rowOrigin_, std::move(origin));
84 static std::expected<void, TreeError>
85 validateModelOrigin(
ManagedScene &scene,
const std::shared_ptr<portals::detail::ManagedOrigin> &origin) {
86 auto live = origin->check();
90 if (origin->tree != &scene.app_.tree() || !scene.app_.tree().contains(scene.root_, origin->node).value_or(
false)) {
96 static bool modelSceneClosed(
const ManagedScene &scene)
noexcept {
101 return source.state_;
104 template <std::equality_comparable T>
110 template <std::equality_comparable T>
113 auto property = state.lock();
115 return std::unexpected(property.error());
117 if (state.scene_ != scene.root_.id()) {
124 template <
class T>
static void editDeclaration(
ManagedModel<T> model, std::shared_ptr<void> declaration) {
125 if (
auto source = model.lock()) {
126 (*source)->editDeclaration = std::move(declaration);
131 if (
auto source = model.lock()) {
132 (*source)->sinkOnly =
true;
139 return scene.applyOwnedSnapshot(std::move(model), std::move(snapshot));
145 auto record = navigation.lock();
147 record ? std::dynamic_pointer_cast<portals::detail::ManagedModelSourceOf<T>>((*record)->model.lock()) :
nullptr;
148 if (!source || source->retired || (*record)->scene != scene.root_.id()) {
153 result.source_ = source;
154 result.owner_ = scene.owner_;
159 auto record = navigation.record_.lock();
160 if (!record || !scene.navigation_) {
163 auto current = record->current.model_.lock();
164 auto selection = record->selection.model_.lock();
165 auto reading = record->reading.model_.lock();
166 record->closed =
true;
167 std::erase(scene.navigation_->contexts, record);
168 std::erase_if(scene.properties_, [&](
const auto &property) {
169 return property == current || property == selection || property == reading;
175 auto property = state.model_.lock();
177 std::erase(scene.properties_, std::shared_ptr<void>(std::move(property)));
182 template <std::equality_comparable T>
184 auto property = state.model_.lock();
189 std::erase(scene.properties_, std::shared_ptr<void>(property));
194 static void reportValueError(
const std::shared_ptr<RefTarget> &target,
ManagedError &failure,
195 std::source_location origin,
const char *operation =
"model.value",
196 const char *control =
"Model")
noexcept {
200 if (target && target->owner == std::this_thread::get_id() && target->scene && !target->lifetime.expired()) {
201 target->scene->reportShortError(failure, operation, {}, control, origin);
208 static std::expected<ModelResource, TreeError> registeredModelResource(
const ManagedModel<T> &model) {
209 auto source = model.lock();
210 if (!source || (*source)->retired || !(*source)->model) {
214 return (*source)->navigationResource;
217 template <
class T>
static std::expected<std::string, TreeError> formatValueCaption(
const T &value) {
218 if constexpr (std::same_as<T, GraphemeText>) {
219 return std::expected<std::string, TreeError>(std::in_place, value.bytes());
220 }
else if constexpr (std::same_as<T, std::string>) {
221 return std::expected<std::string, TreeError>(std::in_place, value.data(), value.size());
223 const auto text = std::format(
"{}", value);
226 return std::expected<std::string, TreeError>(std::in_place, text.data(), text.size());
232 struct ValueCaptionGraph {
235 std::shared_ptr<void> output;
236 std::vector<std::shared_ptr<ManagedScene::ObserverRecord>> observers =
237 std::vector<std::shared_ptr<ManagedScene::ObserverRecord>>(
238 std::initializer_list<std::shared_ptr<ManagedScene::ObserverRecord>>{});
239 std::shared_ptr<void> payload;
241 ~ValueCaptionGraph() {
246 for (
const auto &observer : observers) {
247 observer->retired =
true;
250 for (
const auto &observer : observers) {
251 observer->subscription = {};
252 std::erase(scene->observers_, observer);
256 std::erase(scene->properties_, output);
262 static std::expected<ManagedState<std::string>,
ManagedError>
263 valueTextState(
ManagedScene &scene,
const std::string &initial,
const std::shared_ptr<ValueCaptionGraph> &graph) {
264 auto state = scene.state(initial);
266 return std::unexpected(state.error());
269 graph->output = *state->lock();
274 template <
class Compute>
static auto computeValueText(
ManagedScene &scene, Compute &&compute) {
281 } guard{scene.observerCallbacks_};
283 ++scene.observerCallbacks_;
285 return std::invoke(std::forward<Compute>(compute));
288 template <std::equality_comparable T>
291 std::function<std::expected<void, TreeError>()> callback,
292 const std::shared_ptr<ValueCaptionGraph> &graph) {
293 auto observed = scene.observe(node, source, [callback = std::move(callback)](
const T &) {
300 const auto record = scene.observers_.back();
303 record->retired =
true;
304 record->subscription = {};
305 std::erase(scene.observers_, record);
310 record->successful = (*snapshot)->revision;
311 record->initialPending =
false;
312 record->operation =
"text.compute";
313 graph->observers.push_back(record);
320 auto admitted = scene.observerAdmission(node);
325 const auto boundModels = std::ranges::count_if(scene.models_, [](
const auto &source) {
326 return source->bound();
328 const auto nodeObservers = std::ranges::count(scene.observers_,
Node<Widget>(node), [](
const auto &record) {
331 const auto captures = std::ranges::count_if(scene.liveText_, [&](
const auto &record) {
332 return record->origin->node == node;
334 const auto used = scene.observers_.size() + scene.liveText_.size() +
static_cast<std::size_t
>(boundModels);
335 const auto nodeUsed =
static_cast<std::size_t
>(nodeObservers + captures);
337 if (count > scene.options_.maxObservers - used || count > scene.options_.maxObserversPerNode - nodeUsed) {
344 struct ValueCaptionSlot {
345 const void *identity{};
346 std::shared_ptr<ValueCaptionBinding> source;
352 return std::unexpected(allowed.error());
355 auto entry = scene.find(node);
360 return ValueCaptionSlot{entry->caption.get(), entry->caption ? entry->caption->source :
nullptr};
363 template <
class Receiver>
364 static std::expected<void, ManagedError>
366 std::shared_ptr<ValueCaptionBinding> source,
const void *previous,
MountContext &context) {
367 auto slot = valueCaptionSlot(scene, node);
369 return std::unexpected(slot.error());
371 if (slot->identity != previous) {
375 auto candidate = std::make_unique<ManagedScene::CaptionBinding>();
377 if constexpr (std::same_as<Receiver, Border>) {
378 candidate->node = node;
382 candidate->model = text;
383 candidate->source = std::move(source);
385 auto retired = std::make_shared<std::unique_ptr<ManagedScene::CaptionBinding>>();
387 context.
release.emplace_back([retired] {
397 auto entry = scene.find(node);
398 entry->caption.swap(candidate);
399 retired->swap(candidate);
407 template <std::equality_comparable T,
class Projection>
408 static std::expected<ManagedState<std::string>,
ManagedError>
410 const std::shared_ptr<Projection> &projection,
const std::shared_ptr<ValueCaptionGraph> &graph) {
411 auto admitted = scene.observerAdmission(node);
413 return std::unexpected(admitted.error());
416 graph->observers.reserve(1);
419 auto text = scene.derive(source, [projection](
const T &value) -> std::expected<std::string, TreeError> {
420 if constexpr (std::is_member_pointer_v<Projection> || std::is_pointer_v<Projection>) {
426 decltype(
auto) projected = std::invoke(*projection, value);
428 if constexpr (portals::detail::IS_DERIVED_EXPECTED<std::remove_cvref_t<
decltype(projected)>>) {
429 return projected ? formatValueCaption(*projected)
430 : std::expected<std::string, TreeError>(std::unexpected(projected.error()));
432 return formatValueCaption(projected);
436 return std::unexpected(text.error());
439 graph->output = *text->state_.lock();
440 graph->observers.push_back(scene.observers_.back());
441 graph->observers.back()->
node = node;
447 return scene.choiceWithin(root, node);
450 template <
class Callback>
452 std::source_location origin) {
454 adapter = scene.actionAdapter<
ChoiceSelection>(std::move(callback), origin),
456 auto result = adapter(value);
457 if (!result && !
lifetime.expired() && !scene.commandReported(result,
lifetime)) {
464 const auto count = scene.models_.size();
465 context.
rollback.push_back([&scene, count] {
466 while (scene.models_.size() > count) {
467 scene.models_.back()->retire();
468 scene.models_.pop_back();
475 auto entry = scene.find(owner);
479 entry->companion = popup;
484 std::shared_ptr<portals::detail::FindModelSource> source = {},
485 std::shared_ptr<portals::detail::FindExternalBinding> external = {});
494 std::string_view document);
496 std::source_location origin);
501 std::shared_ptr<std::weak_ptr<portals::detail::FormFieldRecord>> bridge = {},
502 std::function<Description<Label>(
ControlStyle)> captionRecipe = {});
504 std::shared_ptr<portals::detail::EditTextBinding>);
506 std::function<
void()>);
507 static std::expected<void, ManagedError>
515 static std::expected<std::shared_ptr<portals::detail::FormFieldRecord>,
ManagedError> fieldRecord(
ManagedScene &scene,
524 if (scene.owner_ == std::this_thread::get_id()) {
531 if (scene.owner_ == std::this_thread::get_id()) {
540 return scene.lifetime_;
549 return scene.makeDialogPanel(node, options);
558 auto reserved = NotificationAccess::reserve(center);
563 context.release.emplace_back([center] {
564 NotificationAccess::release(center);
567 NotificationAccess::release(center);
570 auto made = scene.makeNotifications(wrapper, body, options, context.nodes);
572 return std::unexpected(made.error());
574 context.finalize.emplace_back([&scene, record = *made] {
575 return scene.finalizeNotifications(record);
577 context.publish.emplace_back([center, record = *made] {
578 NotificationAccess::publish(center, record);
598 static std::expected<Node<T>, ManagedError>
mount(Description<T> &&description, ManagedScene &scene,
599 Node<Widget> parent, MountContext &context);
603 template <
class T>
static bool needsGridContext(
const Description<T> &description);
605 template <
class T>
static bool needsChoiceHost(
const Description<T> &description);
606 template <
class T>
static std::expected<bool, ManagedError> prepareChoiceHost(Description<T> &, ControlContext);
607 template <
class T,
class Probe>
static Description<T> choiceProbe(Description<T>, Probe);
608 template <
class T>
static Description<T> choiceHost(Description<T> description,
bool explicitHost =
false);
626 template <
class T,
class Factory>
static Description<T>
describe(Factory factory);
633 template <
class T>
static Description<T>
intrinsicStyle(Description<T> description, StyleTarget identity);
639 template <
class T>
static void preparedControl(Description<T> &description, std::uint32_t alreadyMaterialized = 0);
665 static Description<Dialog>
messageControl(Description<Dialog> description);
674 static std::expected<void, ManagedError>
messageSource(Description<T> &description,
const ControlSettings &settings,
675 ControlPropertyPresence materialized,
676 ControlFactoryKind kind = ControlFactoryKind::MESSAGE_BINDING);
681 static Description<Dialog>
internalDialog(Description<Dialog> description,
682 const TextValue *prechargedTitle =
nullptr);
691 static Description<T>
configuredControl(Description<T> description, std::string_view type,
bool inherit =
true);
698 template <
class T>
static Description<T>
controlArguments(Description<T> description, ControlSettings arguments);
702 template <
class T>
static Description<T>
failed(ManagedError failure);
707 template <
class T>
static void numericSettings(Description<T> &description, ControlSettings patch);
712 template <
class Parent,
class Child>
713 static void layoutChild(Description<Parent> &parent, Description<Child> &child,
bool structural =
false);
718 template <
class... Children>
static std::shared_ptr<RecipeLayout>
captureLayouts(Children &...children);
723 template <
class T>
static Description<T>
withLayout(Description<T> description, std::shared_ptr<RecipeLayout> layout);
727 template <
class Child>
728 static void gridChild(Description<Grid> &parent, Child &&child, std::optional<GridRegion> region = {});
730 static void gridSection(Description<Grid> &parent, GridSection section);
740 return result ? std::expected<void, ManagedError>{} : std::unexpected(error(node, result.error()));
793 std::shared_ptr<ScrollController> controller,
ControlStyle style);
808 template <
class T>
static constexpr std::string_view
controlType() {
809 if constexpr (std::same_as<T, Label>) {
811 }
else if constexpr (std::same_as<T, Button>) {
813 }
else if constexpr (std::same_as<T, CheckBox>) {
815 }
else if constexpr (std::same_as<T, Switch>) {
817 }
else if constexpr (std::same_as<T, ThreeState>) {
819 }
else if constexpr (std::same_as<T, FormField>) {
821 }
else if constexpr (std::same_as<T, FindBar>) {
823 }
else if constexpr (std::same_as<T, LineEdit>) {
825 }
else if constexpr (std::same_as<T, Password>) {
827 }
else if constexpr (std::same_as<T, Row>) {
829 }
else if constexpr (std::same_as<T, RadioGroup>) {
831 }
else if constexpr (std::same_as<T, StatusBar>) {
833 }
else if constexpr (std::same_as<T, Column>) {
835 }
else if constexpr (std::same_as<T, Border>) {
837 }
else if constexpr (std::same_as<T, Gauge>) {
839 }
else if constexpr (std::same_as<T, Spinner>) {
841 }
else if constexpr (std::same_as<T, SpinBox>) {
843 }
else if constexpr (std::same_as<T, Slider>) {
845 }
else if constexpr (std::same_as<T, ScrollArea>) {
847 }
else if constexpr (std::same_as<T, DocumentView>) {
848 return "DocumentView";
849 }
else if constexpr (std::same_as<T, LogView>) {
851 }
else if constexpr (std::same_as<T, ScrollBar>) {
853 }
else if constexpr (std::same_as<T, HelpView>) {
855 }
else if constexpr (std::same_as<T, KeyHints>) {
858 return "VirtualList";
860 return "VirtualTable";
863 }
else if constexpr (std::same_as<T, DataStateView>) {
864 return "DataStateView";
865 }
else if constexpr (std::same_as<T, OverlayHost>) {
866 return "OverlayHost";
867 }
else if constexpr (std::same_as<T, Dialog>) {
869 }
else if constexpr (std::same_as<T, Overlay>) {
880 mergeRecipeControlSettings(base, patch);
891 (void)std::move(description).scalarSettings(std::move(patch));
907 auto entry = scene.find(node);
915 const auto current = entry->target;
918 return std::unexpected(
922 if (current && !current->type.empty() && (!identity.
control || current->control)) {
923 const auto containsName = [&](
const std::string &name) {
924 return name == current->type || std::ranges::find(current->baseTypes, name) != current->baseTypes.end();
927 if (containsName(identity.
type) && std::ranges::all_of(identity.
baseTypes, containsName)) {
940 if (target.type.empty()) {
941 target.type = identity.
type;
944 const auto retainName = [&](
const std::string &name) {
945 if (name != target.type && std::ranges::find(target.baseTypes, name) == target.baseTypes.end()) {
946 target.baseTypes.push_back(name);
950 retainName(identity.
type);
952 for (
const auto &name : identity.
baseTypes) {
956 target.control = target.control || identity.
control;
964 return scene.style(node, std::move(target));
965 }
catch (
const std::bad_alloc &) {
971 template <
class T,
class Factory>
static Description<T> cold(Factory factory);
974 ++scene.coldMountPending_;
979 std::shared_ptr<ManagedScene::LiveTextRecord> live;
980 std::shared_ptr<void> output;
981 std::shared_ptr<ManagedScene::ObserverRecord> observer;
982 std::shared_ptr<portals::detail::ManagedModelSource> model;
985 void retire() noexcept {
988 --scene->coldMountPending_;
992 observer->retired =
true;
995 observer->subscription = {};
998 std::erase(scene->models_, model);
1001 std::erase(scene->observers_, observer);
1004 std::erase(scene->properties_, output);
1005 std::erase_if(scene->originProperties_, [&](
const auto &record) {
1006 return record.property.lock() == output;
1010 live->origin->retired =
true;
1011 scene->pruneLiveText();
1016 static std::shared_ptr<RefTarget> captionIdentity(
const TextSource &source) {
1017 return source.target_;
1020 static std::shared_ptr<RefTarget> captionTarget(std::shared_ptr<RefTarget> target, MountContext &context) {
1021 for (
const auto &pending : context.pending) {
1022 if (pending.identity == target.get()) {
1023 return std::make_shared<RefTarget>(pending.target);
1029 static std::expected<void, ManagedError> finishCaptions(MountContext &context) {
1034 std::vector<std::optional<std::size_t>> dependencies(context.captions.size());
1035 for (std::size_t index = 0; index < context.captions.size(); ++index) {
1036 auto target = captionTarget(context.captions[index].source, context);
1038 return std::unexpected(error(context.captions[index].receiver,
TreeError::CLOSED));
1040 if (target->owner != std::this_thread::get_id()) {
1043 for (std::size_t source = 0; source < context.captions.size(); ++source) {
1044 if (context.captions[source].receiver == target->node) {
1045 dependencies[index] = source;
1053 for (std::size_t index = 0; index < context.captions.size(); ++index) {
1054 auto &caption = context.captions[index];
1055 if (caption.completed || (dependencies[index] && !context.captions[*dependencies[index]].completed)) {
1058 auto completed = caption.complete();
1062 caption.completed =
true;
1074 static std::expected<void, ManagedError> completeCaption(ManagedScene &scene, Node<Control> node,
1075 const TextSource &source, MountContext &context,
1076 const std::shared_ptr<ColdGraph> &graph) {
1077 auto target = captionTarget(source.target_, context);
1081 if (target->owner != std::this_thread::get_id()) {
1084 auto owner = eventScene(target);
1086 return std::unexpected(owner.error());
1088 if (*owner != &scene) {
1091 const bool existed = std::ranges::any_of(scene.liveText_, [&](
const auto &record) {
1092 return record->origin->node == target->node && record->kind == static_cast<int>(source.kind_);
1095 scene.attachLiveText(TextSource(target, source.kind_), PropertyOptions{}, std::source_location::current(),
false);
1097 return std::unexpected(
live.error());
1100 const auto created = std::ranges::find_if(scene.liveText_, [&](
const auto &record) {
1101 return record->origin == live->state_.origin_;
1103 if (created != scene.liveText_.end()) {
1104 graph->live = *created;
1108 auto initial = TextSource(target, source.kind_).snapshot();
1110 return std::unexpected(initial.error());
1112 auto applied =
setControlText(scene.app_.tree(), node, std::move(*initial));
1114 return std::unexpected(error(node, applied.error()));
1116 auto observed = scene.observe(node, *live, [&scene, node](
const GraphemeText &text) {
1122 graph->observer = scene.observers_.back();
1123 graph->observer->operation =
"text.caption";
1124 if (graph->pending) {
1125 --scene.coldMountPending_;
1126 graph->pending =
false;
1131 static std::expected<void, ManagedError> completeTextList(ManagedScene &scene, Node<VirtualList<TextSegment>> node,
1132 const TextSource &source,
bool splitWords,
1133 TextSplitOptions options, MountContext &context,
1134 const std::shared_ptr<ColdGraph> &graph,
1136 auto target = source.target_;
1137 for (
const auto &pending : context.pending) {
1138 if (pending.identity == target.get()) {
1139 target = std::make_shared<RefTarget>(pending.target);
1143 if (target && target->owner != std::this_thread::get_id()) {
1149 const bool existed = std::ranges::any_of(scene.liveText_, [&](
const auto &record) {
1150 return record->origin->node == target->node && record->kind == static_cast<int>(source.kind_);
1152 auto resolved = TextSource(target, source.kind_);
1153 auto live = scene.attachLiveText(resolved, PropertyOptions{}, std::source_location::current(),
false);
1155 return std::unexpected(
live.error());
1157 const auto existing = std::ranges::find_if(scene.liveText_, [&](
const auto &record) {
1158 return record->origin == live->state_.origin_;
1161 if (!existed && existing != scene.liveText_.end()) {
1162 graph->live = *existing;
1164 auto initialText =
live->snapshot();
1166 return std::unexpected(error(target->node, initialText.error()));
1168 if ((*initialText)->value.policy() != scene.widthPolicy()) {
1171 auto admitted = scene.observerAdmission(node);
1173 return std::unexpected(admitted.error());
1175 auto textFailure = std::make_shared<std::optional<TextError>>();
1176 auto derived = scene.derive(*live, [splitWords, options, textFailure](
const GraphemeText &text) {
1177 *textFailure = portals::detail::textSplitLimit(text, options.limits);
1181 auto failure = derived.error();
1182 failure.
node = target->node.id();
1183 failure.
text = *textFailure;
1184 return std::unexpected(failure);
1186 graph->output = *derived->state_.lock();
1187 graph->observer = scene.observers_.back();
1188 graph->observer->textFailure = std::move(textFailure);
1189 graph->observer->operation = splitWords ?
"text.words" :
"text.graphemes";
1190 graph->observer->node = node;
1191 scene.originProperties_.push_back({
live->state_.origin_, graph->output, node});
1193 derived->state_.origin_ =
live->state_.origin_;
1195 scene.collectionModel<TextSegment>(derived->state_, CollectionModelOptions{}, portals::detail::segmentRows);
1197 return std::unexpected(model.error());
1199 auto owned = model->lock();
1201 return std::unexpected(error(node, owned.error()));
1203 graph->model = *owned;
1204 graph->model->receiver = node;
1205 auto range = (*owned)->model->openRange();
1207 return std::unexpected(error(node, range.error()));
1209 auto installed = scene.app_.tree().edit(node, [&](VirtualList<TextSegment> &view) {
1210 view.consumer_ = std::move(*range);
1213 return std::unexpected(error(node, installed.error()));
1215 auto attached = scene.attachView(node, *owned, std::move(prepared));
1216 if (attached && graph->pending) {
1217 --scene.coldMountPending_;
1218 graph->pending =
false;
1220 return attached ? std::expected<void, ManagedError>{} : std::unexpected(attached.error());
1234 template <
class Content,
class Initial>
1235 static Description<DataStateView>
dataState(Initial initial, Description<Content> content, DataStateConfig config,
1242 template <
class Factory>
static Description<Widget>
transaction(Factory factory);
1249 template <
class T>
static Description<Widget>
erase(Description<T> description);
1253 static Description<Widget>
forwardOuter(Description<Widget> description);
1268 auto &tree = scene.app_.tree();
1269 const auto read = tree.read(node, [&](
const SizedWidget &widget) {
1274 return std::unexpected(error(node, read.error()));
1277 if (change.dimension == SizeDimension::WIDTH) {
1279 }
else if (change.dimension == SizeDimension::HEIGHT) {
1282 if (change.dimension != SizeDimension::FLEX_Y) {
1288 if (change.dimension != SizeDimension::FLEX_X) {
1297 return changed ? std::expected<void, ManagedError>{} : std::unexpected(error(node, changed.error()));
1312 auto &tree = scene.app_.tree();
1313 const auto read = tree.read(target, [&](
const SizedWidget &widget) {
1318 return std::unexpected(error(target, read.error()));
1321 if (source != target) {
1323 const auto inspected = tree.read(source, [&](
const SizedWidget &widget) {
1328 return std::unexpected(error(source, inspected.error()));
1334 outer.
mode = inner.mode;
1336 outer.
weight = inner.weight;
1344 policy = sizing->apply(policy);
1348 return changed ? std::expected<void, ManagedError>{} : std::unexpected(error(target, changed.error()));
1359 std::optional<bool> visible, std::optional<bool> enabled) {
1366 auto &tree = scene.app_.tree();
1369 const auto changed = tree.setVisible(node, *visible);
1372 return std::unexpected(error(node, changed.error()));
1377 const auto changed = tree.setEnabled(node, *enabled);
1380 return std::unexpected(error(node, changed.error()));