Skip to main content

GenApiError

Enum GenApiError 

Source
#[non_exhaustive]
pub enum GenApiError {
Show 31 variants NodeNotFound(String), Type { name: String, kind: &'static str, expected: &'static str, }, Access { name: String, refused: AccessDirection, }, Locked { name: String, locked_by: String, }, InvalidText { name: String, expected: &'static str, text: String, }, Range { name: String, value: Value, violation: RangeViolation, }, RegisterLength { name: String, len: u32, got: usize, }, Unavailable(String), NoValueSource { name: String, }, NoIndexedValue { name: String, index_node: String, index: i64, }, Io(Box<dyn Error + Send + Sync + 'static>), RegisterEncoding { name: String, width: usize, problem: &'static str, }, Declaration { name: String, problem: &'static str, }, Unsupported { name: String, kind: &'static str, }, ExprParse { name: String, formula: String, source: ParseError, }, ExprEval { name: String, source: EvalError, }, UnknownVariable { name: String, var: String, }, UnknownVariableExtension { name: String, var: String, extension: String, }, EnumValueUnknown { node: String, value: i64, }, EnumEntryUnavailable { node: String, entry: String, }, EnumNoSuchEntry { node: String, entry: String, }, NotAttached { node: String, port: String, }, PortNotWritable { node: String, port: String, }, UnknownPort { node: String, port: String, }, NotDeviceMemory { node: String, port: String, }, PortOutOfRange { node: String, port: String, offset: i64, len: u32, size: usize, }, BadIndirectAddress { name: String, addr: i64, }, BadLength { name: String, length_node: String, len: i64, }, BitfieldOutOfRange { name: String, bit_offset: u16, bit_length: u16, len: usize, }, ValueTooWide { name: String, value: i64, bit_length: u16, }, MaskedWriteUnreadable { name: String, address: u64, },
}
Expand description

Error type produced by GenApi operations.

Every variant names the node it is about. A transport’s failure is the source of GenApiError::Io, and a formula’s of GenApiError::ExprParse and GenApiError::ExprEval: carried, never flattened into text (ADR-0030).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NodeNotFound(String)

The requested node does not exist in the nodemap.

§

Type

The node is of another kind than the operation needs.

Fields

§name: String

The node.

§kind: &'static str

Its kind, as crate::Node::kind_name names it.

§expected: &'static str

What the operation needs, such as "an Integer".

§

Access

The node’s access mode forbids the operation: a read of a WO node, a write of an RO one.

Fields

§name: String

The node.

§refused: AccessDirection

The direction refused.

§

Locked

The node declares pIsLocked and the device currently reports it locked, so the write was refused locally.

Names the locking feature, because that is the actionable part: a caller told only “access denied” has nowhere to go, whereas “ExposureTime is locked by ExposureTime_Lck” points at the feature to change first. See ADR-0018 and backlog GA-06.

Fields

§name: String

The node whose write was refused.

§locked_by: String

The feature named by this node’s pIsLocked.

§

InvalidText

Text given for a feature does not parse as the feature’s type: see crate::NodeMap::set_text. Nothing was written.

Fields

§name: String

The feature.

§expected: &'static str

What the feature takes, such as "an integer".

§text: String

The text as given.

§

Range

The value is outside what the node accepts. Nothing was written.

Fields

§name: String

The node.

§value: Value

The value refused.

§violation: RangeViolation

How it falls outside.

§

RegisterLength

Bytes written to a <Register> are not its length. Nothing was written.

Fields

§name: String

The register.

§len: u32

Its length.

§got: usize

The bytes given.

§

Unavailable(String)

The node is currently not available: its pIsAvailable reads false.

§

NoValueSource

The node has no value of its own to read or write: no register, no <pValue> and no <Value>.

Fields

§name: String

The node.

§

NoIndexedValue

An indexed <Integer> or <Float> has no value for the index its <pIndex> node reads now: no <ValueIndexed> or <pValueIndexed> names it, and there is no <ValueDefault> or <pValueDefault> (GenICam Standard v2.1.1 §2.8.5). Nothing was read or written.

Fields

§name: String

The indexed node.

§index_node: String

Its <pIndex> node.

§index: i64

The index read.

§

Io(Box<dyn Error + Send + Sync + 'static>)

Register I/O failed in the transport. The source is the transport’s error: a GVCP status, a USB failure, a timeout.

§

RegisterEncoding

A register’s bytes cannot be converted to or from the node’s value: an empty payload, a width its encoding has no form for (an IEEE float of three bytes), an unsigned bit field beyond i64.

The bytes are the device’s, or the width the node declares; the XML itself parsed (backlog GA-30).

Fields

§name: String

The node.

§width: usize

The register width in bytes, or the bit-field width in bits for a bit field.

§problem: &'static str

What does not convert, such as "an IEEE float is 4 or 8 bytes".

§

Declaration

The node’s declaration cannot be evaluated: the XML loaded, but declares something a node of its kind cannot have, such as a <Boolean> over a register with no bit field, or a zero scale.

Fields

§name: String

The node.

§problem: &'static str

What is wrong, such as "has a zero <Scale> numerator".

§

Unsupported

A declaration this crate has no builder for.

viva_genapi_xml::NodeDecl is #[non_exhaustive], so a node type added to the XML layer no longer breaks this crate’s build. It surfaces here instead, at nodemap construction, and lands in crate::NodeMap::skipped where the corpus test will see it.

Fields

§name: String

The node.

§kind: &'static str

The declaration’s kind, as viva_genapi_xml::NodeDecl::kind names it.

§

ExprParse

Parsing a formula failed.

Fields

§name: String

The formula node.

§formula: String

The formula, constant or expression as the document writes it.

§source: ParseError

The parser’s error, with the offset into formula.

§

ExprEval

Evaluating a formula failed.

Fields

§name: String

The formula node, or the node whose value the failure was found on.

§source: EvalError

What failed.

§

UnknownVariable

A formula referenced an unknown variable.

Fields

§name: String

The formula node.

§var: String

The variable.

§

UnknownVariableExtension

A formula qualified a <pVariable> with an extension the GenApi standard does not define — anything but .Value, .Min, .Max, .Inc or .Entry.<Name>.

Fields

§name: String

The formula node.

§var: String

The qualified identifier as written.

§extension: String

The part after the variable name’s first ..

§

EnumValueUnknown

Raw register value did not correspond to any enum entry.

Fields

§node: String

The enumeration.

§value: i64

The value read.

§

EnumEntryUnavailable

The enumeration entry exists but cannot be selected now: its pIsImplemented or pIsAvailable reads false. Nothing was written.

Fields

§node: String

The enumeration.

§entry: String

The entry asked for.

§

EnumNoSuchEntry

Attempted to select an enum entry that does not exist.

Fields

§node: String

The enumeration.

§entry: String

The entry asked for.

§

NotAttached

The node reads a chunk or event port, and nothing is attached to it.

A chunk port’s registers address one chunk of a stream buffer, an event port’s one event (GenICam Standard v2.1.1 §2.8.16): there is no device memory behind them to fall back on. Attach a frame’s chunks or a received event first (crate::NodeMap::attach_chunks, crate::NodeMap::attach_event).

Fields

§node: String

The register that was read.

§port: String

Its <pPort>.

§

PortNotWritable

The node is on a chunk or event port, which holds data the camera sent and cannot be written.

Fields

§node: String

The register that was written.

§port: String

Its <pPort>.

§

UnknownPort

The register is on a port the document does not declare, so there is nowhere to read it from.

Fields

§node: String

The register.

§port: String

Its <pPort>.

§

NotDeviceMemory

A device address was asked of a register on a chunk or event port, whose address counts from the start of a chunk or an event, not from device memory: see crate::NodeMap::register_address.

Fields

§node: String

The register.

§port: String

Its <pPort>.

§

PortOutOfRange

The register lies outside the chunk or event data attached to its port.

Fields

§node: String

The register that was read.

§port: String

Its <pPort>.

§offset: i64

The resolved offset; negative on a chunk port counts from the end.

§len: u32

Bytes the register spans.

§size: usize

Bytes attached to the port.

§

BadIndirectAddress

Indirect addressing resolved to an invalid register.

Fields

§name: String

The node.

§addr: i64

The address its <pAddress> or <pIndex> resolved to.

§

BadLength

A <pLength> node reads a length no register can have: negative, beyond u32, or, for device memory, beyond 16 MiB. Nothing was read or written.

Fields

§name: String

The register.

§length_node: String

The node its <pLength> names.

§len: i64

The length it read.

§

BitfieldOutOfRange

Bitfield metadata exceeded the backing register width.

Fields

§name: String

The node.

§bit_offset: u16

The bit field’s first bit.

§bit_length: u16

Its width in bits.

§len: usize

The register’s length in bytes.

§

ValueTooWide

Provided value does not fit into the declared bitfield.

Fields

§name: String

The node.

§value: i64

The value refused.

§bit_length: u16

The bit field’s width.

§

MaskedWriteUnreadable

A bitfield write needs the rest of its register, and the register is write-only with nothing cached.

Writing some bits of a register means sending the whole register, so the other bits have to come from somewhere. For a WO register they cannot come from the device — it refuses the read — and inventing them would silently overwrite whatever the device holds. Refused locally, before anything reaches the wire (backlog GA-31, issue #135).

Fields

§name: String

The node.

§address: u64

Its register’s address.

Implementations§

Source§

impl GenApiError

Source

pub fn io(err: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self

A transport’s failure: err becomes the GenApiError::Io source.

For RegisterIo implementations, so the error a caller sees can be downcast to the transport’s own.

Trait Implementations§

Source§

impl Debug for GenApiError

Source§

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

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

impl Display for GenApiError

Source§

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

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

impl Error for GenApiError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

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