fory_core/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//! Core runtime for Apache Fory's Rust implementation.
19//!
20//! [`Serializer`] statically handles one associated [`Serializer::Target`]. An ordinary local
21//! type serializes itself. A local external structural serializer or manual serializer can
22//! target a type owned by another crate without creating a wrapper value.
23//!
24//! [`Fory`] exposes ordinary roots for self-serializing types and four explicit-serializer roots:
25//! [`Fory::serialize_with`], [`Fory::serialize_to_with`], [`Fory::deserialize_with`], and
26//! [`Fory::deserialize_from_with`]. Fory-owned carrier serializers such as [`VecSerializer`] and
27//! [`HashMapSerializer`] recursively compose child serializers while preserving standard carrier
28//! wire formats.
29//!
30//! Application traits extend [`ForyObject`] and use [`register_trait_type!`] with a closed list of
31//! concrete target types. Concrete targets are dispatched through their registered serializer;
32//! serializer declarations and Rust trait names never appear on the wire.
33
34// Direct lower-level derive users may resolve this crate through `::fory_core`, including
35// doctests where `crate` is the doctest crate instead of this runtime crate.
36extern crate self as fory_core;
37
38pub mod buffer;
39pub mod config;
40pub mod context;
41pub mod error;
42pub mod fory;
43pub mod meta;
44pub mod resolver;
45pub mod row;
46pub mod serializer;
47pub mod type_id;
48pub mod types;
49pub mod util;
50
51// Re-exported for generated macro code.
52pub use paste;
53
54pub use crate::buffer::{Reader, Writer};
55pub use crate::config::Config;
56pub use crate::context::{ReadContext, WriteContext};
57pub use crate::error::Error;
58pub use crate::fory::{Fory, ForyBuilder};
59pub use crate::meta::{compute_field_hash, compute_struct_hash};
60pub use crate::resolver::{RefFlag, RefMode, TypeInfo, TypeResolver};
61pub use crate::serializer::trait_object::ForyObject;
62#[doc(hidden)]
63pub use crate::serializer::{
64 read_data, write_data, ArcSerializer, ArcWeakSerializer, ArraySerializer, BTreeMapSerializer,
65 BTreeSetSerializer, BinaryHeapSerializer, BoxSerializer, HashMapSerializer, HashSetSerializer,
66 LinkedListSerializer, MutexSerializer, OptionSerializer, RcSerializer, RcWeakSerializer,
67 RefCellSerializer, Serializer, StructSerializer, Tuple10Serializer, Tuple11Serializer,
68 Tuple12Serializer, Tuple13Serializer, Tuple14Serializer, Tuple15Serializer, Tuple16Serializer,
69 Tuple17Serializer, Tuple18Serializer, Tuple19Serializer, Tuple1Serializer, Tuple20Serializer,
70 Tuple21Serializer, Tuple22Serializer, Tuple2Serializer, Tuple3Serializer, Tuple4Serializer,
71 Tuple5Serializer, Tuple6Serializer, Tuple7Serializer, Tuple8Serializer, Tuple9Serializer,
72 VecDequeSerializer, VecSerializer,
73};
74pub use crate::type_id::TypeId;
75pub use crate::types::bfloat16::bfloat16 as BFloat16;
76pub use crate::types::float16::float16 as Float16;
77pub use crate::types::{ArcWeak, Date, Decimal, Duration, RcWeak, Timestamp, UnknownCase};