dijkstra3d-core 0.1.0

Voxel-grid Dijkstra and rolling-ball invalidation, ported from seung-lab/dijkstra3d and seung-lab/kimimaro
Documentation
//! Error types for the core crate.

use thiserror::Error;

/// Result alias for fallible operations in this crate.
pub type Result<T> = std::result::Result<T, Dijkstra3dError>;

/// Errors that can be returned by core algorithms.
///
/// All variants must produce stable, machine-readable strings so that the
/// PyO3 wrapper can map them to Python exception types without parsing prose.
#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum Dijkstra3dError {
    /// A source or target voxel index was outside the volume.
    #[error("voxel index {idx} out of bounds for volume of size {volume_size}")]
    OutOfBounds {
        /// Linear index that was out of range.
        idx: u64,
        /// Total voxel count of the volume.
        volume_size: u64,
    },

    /// Connectivity argument was not one of the accepted values (4, 8, 6, 18, 26).
    #[error("invalid connectivity {got}; expected one of {{4, 8, 6, 18, 26}}")]
    InvalidConnectivity {
        /// The connectivity value the caller passed.
        got: u32,
    },

    /// No path exists between source and target under the given constraints.
    ///
    /// Returned by `dijkstra()` when the target is unreachable.
    #[error("target unreachable from source")]
    Unreachable,

    /// `anisotropy` did not match the volume's dimensionality.
    #[error("anisotropy length {got} does not match volume dimensionality {expected}")]
    AnisotropyDimMismatch {
        /// Length of the supplied anisotropy slice.
        got: usize,
        /// Number of spatial dimensions in the volume.
        expected: usize,
    },

    /// `sources` and `max_distances` had different lengths in invalidation ball.
    #[error("sources length {sources} != max_distances length {max_distances}")]
    LengthMismatch {
        /// Length of the sources slice.
        sources: usize,
        /// Length of the max_distances slice.
        max_distances: usize,
    },

    /// Caller supplied an invalid argument (e.g. empty sources list).
    #[error("invalid input: {0}")]
    InvalidInput(String),
}