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