#[non_exhaustive]pub enum Error {
Show 20 variants
RuntimeLoadFailed(LoadFailure),
UnsupportedCapability {
capability: Capability,
refusal: CapabilityRefusal,
},
RuntimeConflict(SelectionFailure),
NativeOperationFailed {
operation: NativeFunction,
},
InitializationFailed(InitializationFailure),
AllocationFailed(AllocationFailure),
UnsupportedCpu,
NotConnected,
InvalidUtf8(Utf8Error),
InvalidCString(NulError),
ConnectionLost,
InvalidFrame(FrameDefect),
InvalidInput(InputDefect),
QueueFull(QueueLimit),
UnexpectedSdkResult(SdkResultDefect),
ResourceLimit {
resource: ResourceKind,
limit: usize,
},
ReceiverRequestNotAccepted {
advertised: bool,
},
SpawnFailed(SpawnFailure),
InvalidState(StateConflict),
Io(Error),
}Expand description
Every error this crate reports, from the core API, the advanced module
and the File API alike.
Each variant says when it occurs. Its text is for diagnostics; match on the variant and its fields rather than on the text.
This enum is marked #[non_exhaustive] so that new error variants can be
added as the NDI SDK surface evolves without constituting a breaking change.
Match arms should include a wildcard _ pattern.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RuntimeLoadFailed(LoadFailure)
No usable NDI library could be selected.
LoadFailure records the library, attempted locations, their origins
and typed LoadRefusal causes. LoadFailure::loaded_any distinguishes
code that loaded and was refused from locations that could not be opened.
Display retains the diagnostic text for every attempt.
- Selecting the NDI runtime (
Runtime::selectand every constructor that selects one): no usable runtime library was found. The message names every location tried and why each was rejected: the file was absent, the operating system could not load it, or it lacks a required entry point. - Opening the File API (
file::FileApi::new): no usable File library was found, with every location tried and the reason for each. A library that provides no family of File entry points is not usable.
Nothing is selected, so the call can be repeated, for example once the
library is installed. A selected File library that lacks the entry
points of one family is reported as Error::UnsupportedCapability
instead, by every operation that needs that family.
UnsupportedCapability
An operation needs a capability this build or the selected runtime does not provide.
refusal is the same typed evidence returned by
Capabilities::status or
file::FileApi::status. Every operation
is refused before reaching the SDK, and Ndi::require_feature
reports the same value in advance. This condition lasts for the process
lifetime: selecting another runtime or supplying missing build declarations
requires a new process or build.
Fields
capability: CapabilityThe capability, the same whichever operation it gates.
refusal: CapabilityRefusalWhy it is unavailable, with the evidence recorded during detection.
RuntimeConflict(SelectionFailure)
Runtime or File library selection conflicts with the process’s native libraries or a selection already in progress.
SelectionFailure identifies the SelectionConflict, library and
selected, requested or foreign module paths without parsing text.
- The runtime options name a library file other than the selected one, ask for the Advanced SDK when the selected runtime is not one, or name any file when the SDK is linked into the program.
- On dynamically loaded, non-Apple ELF targets, an explicit runtime
path is refused while another NDI runtime occupies the process’s
global symbol scope, with
SelectionConflict::ForeignRuntimeInScope. - Loading a native library re-entered runtime or File library selection on the same thread.
- The File API options name a File library other than the selected one, or any library when the File library is linked into the program.
- The File library cannot accompany the selected runtime: on Linux, macOS and Android it needs the Advanced SDK runtime, and it is refused while the process’s global symbol scope holds an NDI runtime other than the selected one, which it would bind to.
NativeOperationFailed
The native SDK did not perform an operation.
It returned the failure value its header gives the operation: false
from an operation that reports success, or null from one that creates
an object (a finder, receiver, sender, router, FrameSync, AV sync or
genlock instance, or a File player or recorder) or returns a source
descriptor; or an internal-error status from AV synchronization.
A source descriptor with neither a name nor an address is
reported the same way. operation names the SDK function. A Discovery Server advertiser or listener the SDK does
not create is reported as Error::InvalidInput instead, because the
SDK refuses only the address it was given.
The SDK gives no further reason. The File library may report one as an event.
Fields
operation: NativeFunctionThe SDK function that failed.
InitializationFailed(InitializationFailure)
NDI runtime initialization failed, with its InitializationFailure.
Returned only for the runtime itself: the SDK refused to start, or the
runtime handle reference count was exhausted. A finder, receiver,
sender or other object the SDK does not create is reported as
Error::NativeOperationFailed, naming the creating function. A
runtime library that cannot be loaded is reported as
Error::RuntimeLoadFailed instead, and one that does not start
because of the CPU as Error::UnsupportedCpu.
AllocationFailed(AllocationFailure)
Storage could not be allocated for an otherwise valid operation.
AllocationFailure identifies the storage and its requested size
when known. Discovery copies, image encoding scratch, queued sender
bookkeeping, allocator leases and crate-owned receive buffers all
report this condition here. The lossy WebP encoder’s own storage is
the exception: its supported error API cannot classify allocation
failures, so they remain FrameDefect::EncodingFailed inside
Error::InvalidFrame. A configured budget refusal is instead
Error::ResourceLimit.
UnsupportedCpu
The selected NDI runtime cannot run on this CPU.
The runtime did not start and reports that the CPU lacks instructions
it requires. Which instructions those are depends on the SDK version
and the platform. Runtime::is_supported_cpu
answers the same question without starting NDI.
NotConnected
The SDK sent nothing because nothing is connected.
A receiver sends metadata upstream to the source it is connected to,
and Processing.NDI.Recv.h documents a refusal as meaning that it is
connected to none. A later attempt can succeed once it has connected.
InvalidUtf8(Utf8Error)
Text is not UTF-8; the original std::str::Utf8Error retains its offsets.
Reported for standalone received metadata frames and strings a receiver
returns, such as its source’s web-control URL, and for application metadata
passed as a std::ffi::CStr to borrowed audio and video frame builders.
Unreadable per-frame
video/audio metadata is withheld without discarding the media; inspect
crate::FrameMetadataStatus instead. Text a peer advertises through a Discovery Server is
decoded lossily instead.
InvalidCString(NulError)
Text passed to the SDK contains a NUL byte, which a C string cannot hold.
ConnectionLost
A receiver reported the SDK error frame: its connection was lost.
InvalidFrame(FrameDefect)
A frame, or a value describing media, is invalid; FrameDefect identifies the cause.
Shared layout checks use FrameDefect::Layout with a LayoutDefect.
- A frame the SDK delivered (video, audio, metadata or a compressed packet) fails validation: its dimensions, format, strides, sizes or pointers are inconsistent, or a standalone metadata frame has no terminator within the limit.
- A frame, packet or buffer being built, converted or sent does not match its format: a buffer is too small, a dimension, stride or rate is out of range, or a format cannot be used for the operation. This includes a compressed frame the SDK would discard instead of delivering it.
- A frame’s colour description is malformed, conflicting or withheld with its metadata; its HDR transfer is refused; its image dimensions exceed the codec’s limits; or an image encoder fails.
Unreadable optional video/audio metadata is withheld instead of failing
capture; crate::FrameMetadataStatus reports its condition. Withheld
metadata can still fail a later colour-description read.
A value that describes no one frame, such as a compressed audio or video
format, a FrameSync or AV sync audio request, or an allocation, clock or
remote-control value of the advanced module, is Error::InvalidInput
when it is out of range.
InvalidInput(InputDefect)
A value passed to the crate cannot be used; InputDefect identifies the cause.
Standalone aspect ratios, frame rates, compressed audio or video formats,
FrameSync and AV sync audio requests, clock requests and allocation strides
use InputDefect::Layout with a LayoutDefect.
It is out of range, malformed, or conflicts with another setting: for
example a timeout above MAX_TIMEOUT, a relative
library path, a receive delay above two seconds, a PTZ value outside
its range, malformed Advanced configuration JSON, more than one
Discovery Server for a listener, allocator limits that cannot all be
reached, a registration handed to an advertiser that did not issue it,
a compressed audio or video format, an allocation stride or buffer, a
FrameSync or AV sync audio request, a clock quantity or a remote control
value out of the range the SDK accepts, or a File API name, path or option the File library cannot
take. The message says which value and why, and nothing reaches the
SDK, with one exception: the SDK creates a Discovery Server advertiser
or listener for any address it can parse, so when it creates none, the
address it was given, or the lack of one, is reported here.
QueueFull(QueueLimit)
A bounded queue is full. The same call can succeed once queued work
has completed, with nothing else changed; the QueueLimit says
which queue and limit.
advanced::QueuedSender::try_submit, when the frame would take the queue past its frame limit (QueueLimit::Frames) or the retained frames leave insufficient byte capacity (QueueLimit::Bytes). A frame exceeding the entire byte limit getsError::InvalidInput. The frame comes back in theRejected; collect completed frames and submit it again.- An operation of an async File handle, when the handle’s command
queue is full (
QueueLimit::FileCommands). A request to stop is refused only when another one already waits beyond the full queue. - A recorder’s submitted
finishandwait_for_finishoperations, when their separate pending-wait budget is full (QueueLimit::FileFinishWaits). Ordinary commands remain available. file::AsyncFilePlayer::probe, when the probes waiting for the process’s probe thread fill its queue (QueueLimit::FileProbes).
UnexpectedSdkResult(SdkResultDefect)
A value the SDK returned, other than a frame, breaks the SDK’s
documented contract.
SdkResultDefect identifies that contract breach.
For example a negative connection count, a receive delay outside the
range the SDK accepts, a string without a terminator within its limit,
a finder or Discovery Server snapshot, or an event batch, that is malformed, a
send-completion callback for a frame the SDK
was not handed or had already returned, negative encoder guidance, an
unknown AV sync status, an AV sync format change to a sample rate or
channel count that is not positive, or a File SDK result that cannot
be represented. Malformed
frames are reported as Error::InvalidFrame, and text that is not
UTF-8 as Error::InvalidUtf8. Ordinary resource-budget ceilings are
Error::ResourceLimit instead.
ResourceLimit
Discovery data exceeded a per-copy or whole-discovery resource limit.
No partial result is returned. resource identifies the exhausted
count or byte budget; limit is its maximum.
Fields
resource: ResourceKindThe resource whose budget was exhausted.
ReceiverRequestNotAccepted
A Discovery Server listener did not send a request, because no receiver it lists accepts it.
Unlike Error::UnsupportedCapability, this says nothing about the
build or the runtime. A listener lists nothing until it has connected
to its server, so a request made right after it was created can be
refused with advertised false and succeed later.
Fields
SpawnFailed(SpawnFailure)
An async blocking operation could not run.
SpawnFailure distinguishes a missing Tokio runtime context from a
cancelled blocking task. A panic in the operation or its callback is
resumed on the awaiting task with its original payload, after SDK frame
guards are released on the worker. Dropping the future discards its
result and any panic payload; it does not deliver an error to that caller.
§Example
use grafton_ndi::{Error, SpawnFailure};
fn handle_error(error: Error) {
match error {
Error::SpawnFailed(SpawnFailure::NoRuntime) => {
eprintln!("Await this operation inside a Tokio runtime");
}
Error::SpawnFailed(SpawnFailure::TaskCancelled) => {
eprintln!("The runtime cancelled the blocking task");
}
error => eprintln!("{error}"),
}
}InvalidState(StateConflict)
A File API operation is not permitted in the current state of its recorder or async handle.
The StateConflict says which state forbids
it, and StateConflict::is_retryable
whether the same call can succeed later without anything else changing.
Io(Error)
An operating-system operation failed.
- File API: resolving a relative path against the current directory, which may be unavailable.
- File API: checking, before a recording starts or rolls over, that
the directory of its first file exists and can be written to, and
that an exact file name does not exist yet
(
AlreadyExists). - File API: starting the thread of an async File handle or probe, or the timer thread that async event waits share.
- Image encoding: the writer given to a frame’s
encode_image_tofailed. The error is the writer’s own.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()