Skip to main content

ferray_core/
lib.rs

1// ferray-core: N-dimensional array type and foundational primitives
2//
3// This is the root crate for the ferray workspace. It provides NdArray<T, D>,
4// the full ownership model (Array, ArrayView, ArrayViewMut, ArcArray, CowArray),
5// the Element trait, DType system, FerrayError, and array introspection/iteration.
6//
7// ndarray is used internally but is NOT part of the public API.
8//
9// When the `no_std` feature is enabled, only the subset of functionality that
10// does not depend on `std` or `ndarray` is compiled: DType, Element, FerrayError
11// (simplified), dimension types (without ndarray conversions), constants, and
12// layout enums. The full Array type and related features require `std`.
13
14#![cfg_attr(not(feature = "std"), no_std)]
15
16#[cfg(not(feature = "std"))]
17extern crate alloc;
18
19// Modules that work in both std and no_std modes
20pub mod constants;
21pub mod dimension;
22pub mod dtype;
23pub mod error;
24pub mod layout;
25pub mod record;
26
27// Modules that require std (depend on ndarray or std-only features)
28#[cfg(feature = "std")]
29pub mod array;
30#[cfg(feature = "std")]
31pub mod buffer;
32#[cfg(feature = "std")]
33pub mod creation;
34#[cfg(feature = "std")]
35pub mod dynarray;
36#[cfg(feature = "std")]
37pub mod indexing;
38#[cfg(feature = "std")]
39pub mod manipulation;
40#[cfg(feature = "std")]
41pub mod nditer;
42#[cfg(feature = "std")]
43pub mod ops;
44#[cfg(feature = "std")]
45pub mod prelude;
46
47// Re-export key types at crate root for ergonomics (std only)
48#[cfg(feature = "std")]
49pub use array::ArrayFlags;
50#[cfg(feature = "std")]
51pub use array::aliases;
52#[cfg(feature = "std")]
53pub use array::arc::ArcArray;
54#[cfg(feature = "std")]
55pub use array::cow::CowArray;
56#[cfg(feature = "std")]
57pub use array::display::{get_print_options, set_print_options};
58#[cfg(feature = "std")]
59pub use array::owned::Array;
60#[cfg(feature = "std")]
61pub use array::view::ArrayView;
62#[cfg(feature = "std")]
63pub use array::view_mut::ArrayViewMut;
64
65pub use dimension::{Axis, Dimension, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
66
67#[cfg(all(feature = "const_shapes", feature = "std"))]
68pub use dimension::static_shape::{
69    Assert, DefaultNdarrayDim, IsTrue, Shape1, Shape2, Shape3, Shape4, Shape5, Shape6,
70    StaticBroadcast, StaticMatMul, StaticSize, static_reshape_array,
71};
72
73pub use dtype::{DType, Element, SliceInfoElem};
74
75pub use error::{FerrayError, FerrayResult};
76
77pub use layout::MemoryLayout;
78
79#[cfg(feature = "std")]
80pub use buffer::AsRawBuffer;
81
82#[cfg(feature = "std")]
83pub use dynarray::DynArray;
84
85#[cfg(feature = "std")]
86pub use nditer::NdIter;
87
88pub use record::FieldDescriptor;
89
90// Re-export proc macros from ferray-core-macros.
91// The derive macro FerrayRecord shares its name with the trait in record::FerrayRecord.
92// Both are re-exported: the derive macro lives in macro namespace, the trait in type namespace.
93pub use ferray_core_macros::{FerrayRecord, promoted_type, s};
94pub use record::FerrayRecord;
95
96// Kani formal verification harnesses (only compiled during `cargo kani`)
97#[cfg(kani)]
98mod verification_kani;