Skip to main content

arrow_ipc/
lib.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! Support for the [Arrow IPC Format]
19//!
20//! The Arrow IPC format defines how to read and write [`RecordBatch`]es to/from
21//! a file or stream of bytes. This format can be used to serialize and deserialize
22//! data to files and over the network.
23//!
24//! There are two variants of the IPC format:
25//! 1. [IPC Streaming Format]: Supports streaming data sources, implemented by
26//!    [StreamReader] and [StreamWriter]
27//!
28//! 2. [IPC File Format]: Supports random access, implemented by [FileReader] and
29//!    [FileWriter].
30//!
31//! See the [`reader`] and [`writer`] modules for more information.
32//!
33//! [Arrow IPC Format]: https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc
34//! [IPC Streaming Format]: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format
35//! [StreamReader]: reader::StreamReader
36//! [StreamWriter]: writer::StreamWriter
37//! [IPC File Format]: https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format
38//! [FileReader]: reader::FileReader
39//! [FileWriter]: writer::FileWriter
40//!
41//! # Platform Support
42//!
43//! Only little-endian platforms are officially supported and tested in CI.
44//! Big-endian platforms are not tested in CI and may not work correctly.
45//! Fixes for big-endian platforms are welcome and handled on a best-effort basis,
46//! but compatibility is not guaranteed.
47
48#![doc(
49    html_logo_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_white-bg.svg",
50    html_favicon_url = "https://arrow.apache.org/img/arrow-logo_chevrons_black-txt_transparent-bg.svg"
51)]
52#![cfg_attr(docsrs, feature(doc_cfg))]
53#![warn(missing_docs)]
54pub mod convert;
55pub mod reader;
56pub mod writer;
57
58mod compression;
59
60#[cfg(test)]
61mod tests;
62
63// This code is generated so we don't want to fix any lint violations manually
64#[allow(clippy::allow_attributes)]
65#[allow(mismatched_lifetime_syntaxes)]
66#[allow(clippy::redundant_closure)]
67#[allow(clippy::needless_lifetimes)]
68#[allow(clippy::extra_unused_lifetimes)]
69#[allow(clippy::redundant_static_lifetimes)]
70#[allow(clippy::redundant_field_names)]
71#[allow(non_camel_case_types)]
72#[allow(missing_docs)] // Because this is autogenerated
73pub mod r#gen;
74
75pub use self::r#gen::File::*;
76pub use self::r#gen::Message::*;
77pub use self::r#gen::Schema::*;
78pub use self::r#gen::SparseTensor::*;
79pub use self::r#gen::Tensor::*;
80
81const ARROW_MAGIC: [u8; 6] = *b"ARROW1";
82const CONTINUATION_MARKER: [u8; 4] = [0xff; 4];
83
84impl Endianness {
85    /// Returns true if the endianness of the source system matches the endianness of the target system.
86    pub fn equals_to_target_endianness(self) -> bool {
87        match self {
88            Self::Little => cfg!(target_endian = "little"),
89            Self::Big => cfg!(target_endian = "big"),
90            _ => false,
91        }
92    }
93}