Skip to main content

NodeMap

Struct NodeMap 

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

Runtime nodemap built from an [XmlModel] capable of reading and writing feature values via a RegisterIo transport.

Implementations§

Source§

impl NodeMap

Source

pub fn version(&self) -> &str

Return the schema version string associated with the XML description.

Source

pub fn node(&self, name: &str) -> Option<&Node>

Fetch a node by name for inspection.

Source

pub fn node_names(&self) -> impl Iterator<Item = &str>

Return an iterator over all node names in the map.

Source

pub fn dependents(&self, name: &str) -> &[String]

Return the list of nodes that should be invalidated when name changes.

Returns an empty slice if the node has no dependents.

Source

pub fn categories(&self) -> Vec<(&str, &[String])>

Return all category nodes as (name, children) pairs.

Source

pub fn nodes_at_visibility(&self, level: Visibility) -> Vec<&str>

Return names of nodes visible at the given level or below.

A node with Visibility::Expert is visible at level Expert and Guru, but not at Beginner.

Source

pub fn try_from_xml(model: XmlModel) -> Result<Self, GenApiError>

Construct a NodeMap from an [XmlModel], validating formulas.

A declaration that cannot be turned into a runtime node is dropped and recorded in NodeMap::skipped rather than failing the whole model. Cameras carry thousands of nodes and only a handful of them matter to any one application; refusing to open a camera because one obscure feature is unrepresentable serves nobody.

Source

pub fn skipped(&self) -> &[SkippedNode]

Declarations this camera has that we do not expose.

Covers both losses: a node the XML parser could not read, and one it read but that could not be turned into a runtime node. Empty for a document we fully understand; anything listed here is worth reporting as a bug. viva-camctl report prints it.

Source

pub fn get_integer( &self, name: &str, io: &dyn RegisterIo, ) -> Result<i64, GenApiError>

Read an integer feature value using the provided transport.

Source

pub fn set_integer( &mut self, name: &str, value: i64, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write an integer feature and update dependent caches.

Source

pub fn get_float( &self, name: &str, io: &dyn RegisterIo, ) -> Result<f64, GenApiError>

Read a floating point feature.

Source

pub fn set_float( &mut self, name: &str, value: f64, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write a floating point feature using the scale/offset conversion.

Source

pub fn get_enum( &self, name: &str, io: &dyn RegisterIo, ) -> Result<String, GenApiError>

Read an enumeration feature returning the symbolic entry name.

Source

pub fn set_enum( &mut self, name: &str, entry: &str, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write an enumeration entry.

Source

pub fn enum_entries(&self, name: &str) -> Result<Vec<String>, GenApiError>

List the available entry names for an enumeration feature.

Source

pub fn is_implemented( &self, name: &str, io: &dyn RegisterIo, ) -> Result<bool, GenApiError>

Evaluate pIsImplemented for name, returning true when the feature is implemented by the device.

Absent pIsImplemented defaults to true (matching the GenICam spec: an undeclared predicate means “always implemented”). Evaluation errors propagate to the caller so bad XML is visible rather than silently reported as implemented.

Source

pub fn is_available( &self, name: &str, io: &dyn RegisterIo, ) -> Result<bool, GenApiError>

Evaluate pIsAvailable plus selector gating for name.

Returns false when the feature is not implemented, when pIsAvailable evaluates to zero, or when any selected_if rule is violated by the current selector value. Callers that want pure XML gating without selector checks should use NodeMap::is_implemented instead.

Source

pub fn effective_access_mode( &self, name: &str, io: &dyn RegisterIo, ) -> Result<AccessMode, GenApiError>

Return the effective AccessMode for name given the current device state.

  • If the feature is unavailable (see NodeMap::is_available), the function returns AccessMode::RO — we cannot report “NA” without introducing a new variant, and Studio’s wire protocol carries the availability flag separately.
  • If pIsLocked evaluates truthy, RW downgrades to RO; RO and WO are unaffected.
  • Otherwise the statically declared access mode applies.
Source

pub fn available_enum_entries( &self, name: &str, io: &dyn RegisterIo, ) -> Result<Vec<String>, GenApiError>

Return the subset of enum entries currently reported as available by the device, or the full static list when no entry declares an pIsImplemented/pIsAvailable.

Falling back to the full list preserves current behaviour for XMLs that don’t gate individual entries, so callers stop seeing the stale static list when the new predicates are added and otherwise behave as before.

Source

pub fn get_bool( &self, name: &str, io: &dyn RegisterIo, ) -> Result<bool, GenApiError>

Read a boolean feature.

Source

pub fn set_bool( &mut self, name: &str, value: bool, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write a boolean feature.

Source

pub fn exec_command( &mut self, name: &str, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Execute a command feature by writing a value to the command register.

Source

pub fn register_address( &self, name: &str, io: &dyn RegisterIo, ) -> Result<(u64, u32), GenApiError>

Resolve the device register address and length backing a feature.

This is the addressing half of typed feature access, exposed for callers that need raw register I/O through RegisterIo — a file-transfer buffer, for instance, whose address the XML supplies through <pAddress> and which no typed accessor covers. Address terms, <pIndex> scaling and selector blocks resolve exactly as they do for get_integer and friends, so a caller does not have to reimplement GenICam addressing.

Returns GenApiError::Unavailable for a node that has no addressing of its own because it delegates through <pValue>, and for a selector-mapped node whose current selector value has no block.

Source

pub fn get_converter( &self, name: &str, io: &dyn RegisterIo, ) -> Result<f64, GenApiError>

Read a Converter feature value (float) using the provided transport.

Source

pub fn get_int_converter( &self, name: &str, io: &dyn RegisterIo, ) -> Result<i64, GenApiError>

Read an IntConverter feature value (integer) using the provided transport.

Source

pub fn set_converter( &mut self, name: &str, value: f64, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write a Converter feature value (float) through its <FormulaTo>.

Source

pub fn set_int_converter( &mut self, name: &str, value: i64, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write an IntConverter feature value through its <FormulaTo>.

Source

pub fn get_string( &self, name: &str, io: &dyn RegisterIo, ) -> Result<String, GenApiError>

Read a String feature value using the provided transport.

Source

pub fn set_string( &self, name: &str, value: &str, io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write a String feature value using the provided transport.

Source

pub fn get_register( &self, name: &str, io: &dyn RegisterIo, ) -> Result<Vec<u8>, GenApiError>

Read a <Register> node’s bytes using the provided transport.

Returns the full declared length. For a large block — the Micro-Epsilon scanCONTROL declares FileAccessBuffer as 100 000 bytes — that is hundreds of chunked reads; use NodeMap::register_address and the transport directly when a partial read is what you want.

Source

pub fn set_register( &self, name: &str, data: &[u8], io: &dyn RegisterIo, ) -> Result<(), GenApiError>

Write a <Register> node’s bytes using the provided transport.

data must be exactly the declared length. Unlike NodeMap::set_string, which pads with NULs, a short slice is refused: zero-padding a file-transfer buffer to 100 000 bytes because the caller supplied 12 is data loss, not a convenience.

Trait Implementations§

Source§

impl Debug for NodeMap

Source§

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

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

impl TryFrom<XmlModel> for NodeMap

Source§

type Error = GenApiError

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

fn try_from(model: XmlModel) -> Result<Self, Self::Error>

Performs the conversion.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more