Skip to main content

Module try_construct

Module try_construct 

Source
Expand description

XTypes 1.3 §7.5.4.1.2 — TryConstruct-Apply (C4.7).

When a value does not fit the target member on decode or a setter call (e.g. a string longer than the bound, a sequence over its max length, an enum value outside the value range), the try_construct strategy decides what happens:

  • Discard — discard the value, the member stays unset.
  • UseDefault — ignore the value, set member.default_value.
  • Trim — truncate to the bound (strings + sequences); for other bound violations fall back to discard.

This logic is evaluated only when a bound violation actually exists — un-bounded setters (member type without a bound limit) stay unchanged.

Enums§

TryConstructOutcome
Result of a try-construct evaluation.

Functions§

apply_try_construct
Applies the try_construct strategy to a setter value. If there is no bound violation, the function returns Accept(value) unchanged.