Guide API
Skip to main content

FieldValue

Enum FieldValue 

Source
pub enum FieldValue {
    Text(String),
    Int(i32),
    Bool(bool),
    Bits(u32),
    List(Vec<FieldValue>),
    Custom(Rc<dyn CustomValue>),
}
Expand description

The typed unit of dialog data transfer (the D10 value currency).

Well-known shapes (Text/Int/ Bool/Bits/List) are fully type-checked and interoperate with framework controls and generic consumers. Custom is the open seam for user-invented payloads: the framework moves it opaquely and a consumer downcasts at the edge (runtime-checked; see value_as).

Variants§

§

Text(String)

A text field’s string contents, used by InputLine::value and Memo::value. Produced during a dialog gather walk and consumed during scatter. Replaces the raw TMemoData buffer that TMemo::getData/setData filled in the original.

§

Int(i32)

A numeric value — the currency for integer inputs and scrollbar positions. Produced by numeric input controls and read by the broker when syncing a scrollbar’s current value into a scroller or list viewer.

§

Bool(bool)

A single toggle control’s on/off state. Contrast with Bits, which carries a whole cluster’s bitmask (multiple check boxes or radio buttons packed into one u32).

§

Bits(u32)

A packed bit word — a cluster control’s value (check boxes: a bitmask; radio buttons: the selected index). Faithful to TCluster::value. NOT a packed Color (Color is a 4-variant enum and rides the by-value path).

§

List(Vec<FieldValue>)

An ordered record — the typed image of C++ getData(void *rec)’s offset-addressed child walk (positional, anonymous). See Group::gather_list.

§

Custom(Rc<dyn CustomValue>)

A user-invented payload, carried opaquely. Construct with custom; read with value_as (loud) or as_custom (Option). Equality is pointer identity (two Customs are equal iff they share the Rc).

Implementations§

Source§

impl FieldValue

Source

pub fn custom<T: Any + Debug>(v: T) -> Self

Wrap a user payload as Custom.

Recover the payload on the read side with value_as (descriptive error on mismatch — recommended) or as_custom (Option). See the extensibility guide for the full open-exchange story.

Source

pub fn as_custom<T: Any>(&self) -> Option<Rc<T>>

Read a Custom payload as T, or None if this is not a Custom of type T (fail closed). For a descriptive error instead, use value_as.

Source

pub fn value_as<T: Any>(&self) -> Result<Rc<T>, FieldTypeError>

Read a Custom payload as T, loudly: a type mismatch returns a descriptive FieldTypeError (so stale producer/ consumer wiring announces itself at first execution) rather than a silent None. This is the recommended accessor for third-party components.

Trait Implementations§

Source§

impl Clone for FieldValue

Source§

fn clone(&self) -> FieldValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FieldValue

Source§

fn eq(&self, other: &Self) -> bool

Scalars and List compare by value; Custom compares by pointer identity (Rc::ptr_eq) — the framework cannot compare opaque user payloads by value, so two Customs are equal iff they share the Rc.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CustomValue for T
where T: Any + Debug,

Source§

fn as_any_rc(self: Rc<T>) -> Rc<dyn Any>

Upcast Rc<Self> to Rc<dyn Any> so FieldValue::as_custom / FieldValue::value_as can downcast.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.