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(feature = "no_std", no_std)]
15
16#[cfg(feature = "no_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(not(feature = "no_std"))]
29pub mod array;
30#[cfg(not(feature = "no_std"))]
31pub mod buffer;
32#[cfg(not(feature = "no_std"))]
33pub mod creation;
34#[cfg(not(feature = "no_std"))]
35pub mod dynarray;
36#[cfg(not(feature = "no_std"))]
37pub mod indexing;
38#[cfg(not(feature = "no_std"))]
39pub mod manipulation;
40#[cfg(not(feature = "no_std"))]
41pub mod ops;
42#[cfg(not(feature = "no_std"))]
43pub mod prelude;
44
45// Re-export key types at crate root for ergonomics (std only)
46#[cfg(not(feature = "no_std"))]
47pub use array::ArrayFlags;
48#[cfg(not(feature = "no_std"))]
49pub use array::aliases;
50#[cfg(not(feature = "no_std"))]
51pub use array::arc::ArcArray;
52#[cfg(not(feature = "no_std"))]
53pub use array::cow::CowArray;
54#[cfg(not(feature = "no_std"))]
55pub use array::display::{get_print_options, set_print_options};
56#[cfg(not(feature = "no_std"))]
57pub use array::owned::Array;
58#[cfg(not(feature = "no_std"))]
59pub use array::view::ArrayView;
60#[cfg(not(feature = "no_std"))]
61pub use array::view_mut::ArrayViewMut;
62
63pub use dimension::{Axis, Dimension, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
64
65#[cfg(feature = "const_shapes")]
66pub use dimension::static_shape::{
67    Assert, DefaultNdarrayDim, IsTrue, Shape1, Shape2, Shape3, Shape4, Shape5, Shape6,
68    StaticBroadcast, StaticMatMul, StaticSize, static_reshape_array,
69};
70
71pub use dtype::{DType, Element, SliceInfoElem};
72
73pub use error::{FerrayError, FerrayResult};
74
75pub use layout::MemoryLayout;
76
77#[cfg(not(feature = "no_std"))]
78pub use buffer::AsRawBuffer;
79
80#[cfg(not(feature = "no_std"))]
81pub use dynarray::DynArray;
82
83pub use record::FieldDescriptor;
84
85// Re-export proc macros from ferray-core-macros.
86// The derive macro FerrayRecord shares its name with the trait in record::FerrayRecord.
87// Both are re-exported: the derive macro lives in macro namespace, the trait in type namespace.
88pub use ferray_core_macros::{FerrayRecord, promoted_type, s};
89pub use record::FerrayRecord;
90
91// Kani formal verification harnesses (only compiled during `cargo kani`)
92#[cfg(kani)]
93mod verification_kani;