You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by ch...@apache.org on 2026/10/13 05:40:31 UTC
(fory-site) branch main updated (7f572dd324b -> f45337e50d7)
This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
from 7f572dd324b docs: publish Apache Fory 1.7.7 (#515)
new f3a2fc433cc 🔄 synced local 'docs/object-serialization/' with remote 'docs/object-serialization/'
new f45337e50d7 🔄 synced local 'docs/specification/' with remote 'docs/specification/'
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../rust/basic-serialization.md | 35 ++++++++++++++++++++++
docs/object-serialization/rust/external-types.md | 17 +++++++++++
docs/object-serialization/rust/native.md | 1 +
docs/object-serialization/rust/references.md | 24 +++++++++++++++
docs/specification/xlang_type_mapping.md | 4 +++
5 files changed, 81 insertions(+)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
(fory-site) 01/02: 🔄 synced local 'docs/object-serialization/' with remote 'docs/object-serialization/'
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit f3a2fc433ccb096a0af1a3834505afb8de12d030
Author: chaokunyang <sh...@gmail.com>
AuthorDate: Tue Oct 13 05:40:26 2026 +0000
🔄 synced local 'docs/object-serialization/' with remote 'docs/object-serialization/'
---
.../rust/basic-serialization.md | 35 ++++++++++++++++++++++
docs/object-serialization/rust/external-types.md | 17 +++++++++++
docs/object-serialization/rust/native.md | 1 +
docs/object-serialization/rust/references.md | 24 +++++++++++++++
4 files changed, 77 insertions(+)
diff --git a/docs/object-serialization/rust/basic-serialization.md b/docs/object-serialization/rust/basic-serialization.md
index c2e2fe1f3dd..61fba502e48 100644
--- a/docs/object-serialization/rust/basic-serialization.md
+++ b/docs/object-serialization/rust/basic-serialization.md
@@ -117,6 +117,41 @@ assert_eq!(person, decoded);
| `RefCell<T>` | Interior mutability (runtime borrow checking) |
| `Mutex<T>` | Thread-safe interior mutability |
+`Box`, `Rc`, `Arc`, `RcWeak`, and `ArcWeak` also support `str` and `[T]` as
+their target. For example, `Arc<str>` stores a shared string and `Box<[T]>`
+stores an owned slice. These types work at roots, in derived fields, and inside
+collections in both native and xlang modes.
+
+```rust
+use fory::{Fory, ForyStruct};
+use std::sync::Arc;
+
+#[derive(ForyStruct, Debug, PartialEq)]
+struct Message {
+ text: Arc<str>,
+ values: Arc<[i32]>,
+ #[fory(bytes)]
+ attachment: Box<[u8]>,
+}
+
+let mut fory = Fory::builder().build();
+fory.register::<Message>(100)?;
+let value = Message {
+ text: Arc::from("hello"),
+ values: vec![1, 2, 3].into(),
+ attachment: vec![0, 255].into(),
+};
+let bytes = fory.serialize(&value)?;
+let decoded: Message = fory.deserialize(&bytes)?;
+assert_eq!(value, decoded);
+```
+
+String pointers use the same string format as `String`. Slice pointers use the
+same format as `Vec<T>`: roots select the element's list, dense-array, or binary
+format, while derived fields default to LIST. Use `#[fory(array)]` for a dense
+primitive slice field, `#[fory(bytes)]` for binary, or `#[fory(list(...))]` to
+configure list elements.
+
### Date and Time
| Rust Type | Description |
diff --git a/docs/object-serialization/rust/external-types.md b/docs/object-serialization/rust/external-types.md
index 735c33e7e53..dec8356b54c 100644
--- a/docs/object-serialization/rust/external-types.md
+++ b/docs/object-serialization/rust/external-types.md
@@ -249,6 +249,23 @@ deserialization constructs the holder directly without an additional heap
owner. Compatible schema evolution remains active for an external structural
serializer nested behind any of these wrappers.
+For slices of external targets, use `Box<[UserSerializer]>`,
+`Rc<[UserSerializer]>`, or `Arc<[UserSerializer]>` as the serializer for the
+corresponding pointer to `[third_party::User]`. Fory's `RcWeak` and `ArcWeak`
+support the same syntax. Select it at roots with `serialize_with` and
+`deserialize_with`, or in a derived field:
+
+```rust
+#[derive(ForyStruct)]
+struct SharedUsers {
+ #[fory(with = std::sync::Arc<[UserSerializer]>)]
+ users: std::sync::Arc<[third_party::User]>,
+}
+```
+
+`#[fory(list(element(with = UserSerializer)))]` is also supported on these
+slice fields. Register `UserSerializer` before the first root operation.
+
In a non-skipped derived field, keep every carrier constructor's canonical name
visible, optionally with its module path. This applies both to the field's Rust
type and to a `with` serializer tree. For example, write
diff --git a/docs/object-serialization/rust/native.md b/docs/object-serialization/rust/native.md
index 751a71aabaf..0b856ac82be 100644
--- a/docs/object-serialization/rust/native.md
+++ b/docs/object-serialization/rust/native.md
@@ -106,6 +106,7 @@ Native serialization owns the Rust-specific object surface:
- Enums and union-like models supported by Fory derive macros.
- `Vec`, maps, sets, tuples, arrays, and optional values.
- `Box<T>`, `Rc<T>`, `Arc<T>`, `RcWeak<T>`, and `ArcWeak<T>`.
+- The same smart pointers to `str` and `[T]`, including shared and weak references.
- `RefCell<T>` and `Mutex<T>`.
- Trait objects such as `Box<dyn Trait>`, `Rc<dyn Trait>`, and `Arc<dyn Trait>`.
- Dynamic type dispatch with `Box<dyn Any>`, `Rc<dyn Any>`, and
diff --git a/docs/object-serialization/rust/references.md b/docs/object-serialization/rust/references.md
index 4cbbc01f794..7a28c295961 100644
--- a/docs/object-serialization/rust/references.md
+++ b/docs/object-serialization/rust/references.md
@@ -77,6 +77,30 @@ assert!(Arc::ptr_eq(&decoded[0], &decoded[1]));
## Circular References with Weak Pointers
+Shared strings and slices also preserve identity with reference tracking enabled:
+
+```rust
+use fory::{ArcWeak, Fory};
+use std::sync::Arc;
+
+let fory = Fory::builder().track_ref(true).build();
+let text: Arc<str> = Arc::from("shared");
+let value = (ArcWeak::from(&text), text.clone(), text);
+let bytes = fory.serialize(&value)?;
+let decoded: (ArcWeak<str>, Arc<str>, Arc<str>) = fory.deserialize(&bytes)?;
+assert!(Arc::ptr_eq(&decoded.1, &decoded.2));
+assert!(Arc::ptr_eq(&decoded.0.upgrade().unwrap(), &decoded.1));
+```
+
+The same pattern works with `Rc<str>`, `Rc<[T]>`, and `Arc<[T]>` and their
+Fory weak wrappers. `RcWeak::<str>::new()` and `ArcWeak::<[T]>::new()` create
+empty weak values; expired weak values deserialize as empty. Use Fory's
+`RcWeak` and `ArcWeak` wrappers for serialization of standard-library weak pointers.
+
+Aliases of one allocation must use the same pointee type within a serialized
+graph. For example, share `Arc<[i32]>` consistently; mixing an `Arc<[i32; 2]>`
+with its coerced `Arc<[i32]>` view is unsupported when reference tracking is enabled.
+
To serialize circular references like parent-child relationships or doubly-linked structures, use `RcWeak<T>` or `ArcWeak<T>` to break the cycle.
**How it works:**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
(fory-site) 02/02: 🔄 synced local 'docs/specification/' with remote 'docs/specification/'
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit f45337e50d734a0b2a8bbe32e0c57a18053b266d
Author: chaokunyang <sh...@gmail.com>
AuthorDate: Tue Oct 13 05:40:26 2026 +0000
🔄 synced local 'docs/specification/' with remote 'docs/specification/'
---
docs/specification/xlang_type_mapping.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/specification/xlang_type_mapping.md b/docs/specification/xlang_type_mapping.md
index f764053f127..b584a78fe84 100644
--- a/docs/specification/xlang_type_mapping.md
+++ b/docs/specification/xlang_type_mapping.md
@@ -119,6 +119,10 @@ Notes:
still uses the C# mapping shown above; declaration ownership is not a wire
distinction.
- Python `pyfory.Float16` and `pyfory.BFloat16` are reserved annotation markers; scalar values deserialize as native Python `float`.
+- Rust `Box<str>`, `Rc<str>`, and `Arc<str>` map to `string`. The corresponding
+ pointers to `[T]` retain the `Vec<T>` mapping, including its field annotations
+ for LIST, dense arrays, and binary. `RcWeak` and `ArcWeak` use the same target
+ mapping with nullable reference semantics; these carriers add no wire type IDs.
- Python `BoolArray`, `Int8Array`, `Int16Array`, `Int32Array`, `Int64Array`, `UInt8Array`, `UInt16Array`, `UInt32Array`, `UInt64Array`, `Float16Array`, `BFloat16Array`, `Float32Array`, and `Float64Array` are public dense-array wrappers with list-like sequence behavior.
- Python implementations and declared interfaces of `collections.abc.Sequence`,
`Set`, and `Mapping`, including their mutable variants, map to `list`, `set`,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org