Skip to main content

CommandSet

Struct CommandSet 

Source
pub struct CommandSet { /* private fields */ }
Expand description

A set of commands the framework enables or disables in bulk.

The command space is open/unbounded (commands are namespaced strings, not 0..=255), so there is no trackable-range guard and no all() constructor — “all commands” is not enumerable. The set itself is polarity-neutral; the framework’s enabled-by-default policy lives in Program, which keeps its current set as the complement — a disabled set (a denylist). The enable_cmd/disable_cmd methods mean insert/remove regardless of which polarity a particular owner stores; the polarity-neutral insert / remove aliases are preferred at sites where the set’s meaning is not “enabled commands” (e.g. the disabled set).

§Turbo Vision heritage

Ports TCommandSet (views.h, tcmdset.cpp); the 256-bit array becomes a HashSet<Command> (deviation D1).

Implementations§

Source§

impl CommandSet

Source

pub fn new() -> Self

Build an empty command set.

The returned set contains no commands. Populate it incrementally with enable_cmd / insert or the += operator, or use it as the start of a denylist by calling disable_cmd / insert for each command that should be blocked.

Source

pub fn has(&self, cmd: Command) -> bool

Test whether cmd is a member of this set.

Returns true when the command was previously added and not yet removed. On a disabled set (denylist) the result means the command is blocked; on an enabled set it means the command is active — the interpretation depends on the set’s role, not this method.

Use contains at new call sites as the idiomatic Rust name; use has when mirroring the C++ TCommandSet::has call.

Source

pub fn contains(&self, cmd: Command) -> bool

Idiomatic alias for has — follows Rust collection convention (HashSet::contains). Prefer this name at new call sites.

Source

pub fn enable_cmd(&mut self, cmd: Command)

Add cmd to this set (semantic name: enable the command).

When self is an enabled set, this marks the command as enabled and it will pass the framework’s enabled-command check. When self is a disabled set (denylist — the pattern Program uses internally), prefer the polarity-neutral insert alias to avoid misleading code.

The += operator (AddAssign<Command>) is equivalent.

Source

pub fn disable_cmd(&mut self, cmd: Command)

Remove cmd from this set (semantic name: disable the command).

When self is an enabled set, this marks the command as disabled so it will be greyed out in menus and rejected by status-line items. When self is a disabled set (denylist), prefer the polarity-neutral remove alias instead.

The -= operator (SubAssign<Command>) is equivalent.

Source

pub fn insert(&mut self, cmd: Command)

Polarity-neutral alias for enable_cmd: add cmd to the set.

Prefer insert over enable_cmd when the set’s meaning is not “which commands are currently enabled” — for example, when building a denylist of blocked commands, disabled.insert(cmd) is clearer than disabled.enable_cmd(cmd).

Source

pub fn remove(&mut self, cmd: Command)

Polarity-neutral alias for disable_cmd: remove cmd from the set.

Prefer remove over disable_cmd at denylist sites — see insert for the naming rationale.

Source

pub fn enable_set(&mut self, other: &CommandSet)

Add every command in other to this set (set union).

After this call, self contains every command it previously held plus every command in other. Use to merge two enabled sets, or to re-enable a batch of commands at a denylist site (remove them from the blocked list by calling disabled.disable_set(&to_restore)).

The += / |= operators (AddAssign<&CommandSet> / BitOrAssign<&CommandSet>) are equivalent.

Source

pub fn disable_set(&mut self, other: &CommandSet)

Remove every command in other from this set (set difference).

After this call, self no longer contains any command that appears in other. Use to suppress a batch of commands in an enabled set, or to block a batch of commands by adding them to a denylist.

The -= operator (SubAssign<&CommandSet>) is equivalent.

Source

pub fn is_empty(&self) -> bool

Whether no commands are enabled.

Trait Implementations§

Source§

impl AddAssign<&CommandSet> for CommandSet

set += other — add every command in other (set union, equivalent to enable_set). Idiomatic C++ Pascal set + operator.

Source§

fn add_assign(&mut self, other: &CommandSet)

Performs the += operation. Read more
Source§

impl AddAssign<Command> for CommandSet

set += cmd — add a single command (equivalent to enable_cmd / insert). Use this operator when building a set incrementally: let mut s = CommandSet::new(); s += Command::CUT; s += Command::COPY;

Source§

fn add_assign(&mut self, cmd: Command)

Performs the += operation. Read more
Source§

impl BitAndAssign<&CommandSet> for CommandSet

set &= other — set intersection: retains only commands present in both self and other. Equivalent to the Pascal * operator on sets. Use when you need the overlap of two command sets — for example, to find which commands are enabled in all active views simultaneously.

Source§

fn bitand_assign(&mut self, other: &CommandSet)

Performs the &= operation. Read more
Source§

impl BitOrAssign<&CommandSet> for CommandSet

set |= other — set union (alias for += other); same as enable_set. The |= spelling emphasizes the Boolean-OR semantics over the Pascal-add semantics.

Source§

fn bitor_assign(&mut self, other: &CommandSet)

Performs the |= operation. Read more
Source§

impl Clone for CommandSet

Source§

fn clone(&self) -> Self

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 CommandSet

Source§

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

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

impl Default for CommandSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for CommandSet

Source§

impl PartialEq for CommandSet

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CommandSet

Source§

impl SubAssign<&CommandSet> for CommandSet

set -= other — remove every command in other (set difference, equivalent to disable_set). Idiomatic C++ Pascal set - operator.

Source§

fn sub_assign(&mut self, other: &CommandSet)

Performs the -= operation. Read more
Source§

impl SubAssign<Command> for CommandSet

set -= cmd — remove a single command (equivalent to disable_cmd / remove). Use to revoke a single command from an enabled set or to unblock a single command from a denylist.

Source§

fn sub_assign(&mut self, cmd: Command)

Performs the -= operation. 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.
Source§

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

Source§

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.
Source§

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.
Source§

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.
Source§

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.