Data
LinksPlatform's Platform.Data Class Library for Rust.
This crate provides core data types and traits for the Links Platform — an associative data storage system. It defines the fundamental abstractions for working with links (doublets) in Rust.
Overview
The platform-data crate provides:
LinkType— A trait defining the numeric types that can be used as link identifiersLinks— The core trait for CRUD operations on doublet links storageFlow— Control flow type for iteration operations (Continue/Break)Query— A wrapper for link queries using copy-on-write semanticsPoint— A structure representing a repeating elementHybrid— A type for handling internal and external link referencesLinksConstants— Configuration constants for links storageAddrToRaw/RawToAddr— Converters between address and raw representations
Installation
Add this to your Cargo.toml:
[]
= "0.1.0-beta.3"
Usage
Using the query! macro
use ;
// Create queries using the macro
let q: = query!;
assert_eq!;
// Empty query
let empty: = query!;
assert!;
Working with Flow control
use Flow;
let mut collected = vec!;
// Use Flow with try_for_each by converting to ControlFlow
.try_for_each;
assert_eq!;
// Or use Flow directly with manual iteration
let mut collected2 = vec!;
for i in 0..20
assert_eq!;
Using Point for repeated elements
use Point;
let point = new;
assert_eq!;
assert_eq!;
assert_eq!;
// Iterate over repeated elements
for value in point
Address conversion with Hybrid
use ;
let addr: usize = 100;
// Convert address to raw and back
let raw = AddrToRaw.convert;
let restored = RawToAddr.convert;
assert_eq!;
// Hybrid values
let internal = internal;
assert!;
let external = external;
assert!;
Implementing the Links trait
use ;
// The Links trait provides CRUD operations for doublet links:
// - constants_links() - get storage configuration
// - count_links(query) - count matching links
// - create_links(query, handler) - create new links
// - each_links(query, handler) - iterate over matching links
// - update_links(query, replacement, handler) - update existing links
// - delete_links(query, handler) - delete links
API Reference
Core Types
| Type | Description |
|---|---|
LinkType |
Trait bound for numeric types usable as link identifiers (unsigned integers) |
Links<T> |
Main trait defining CRUD operations for links storage |
Flow |
Control flow enum: Continue or Break for iteration control |
Query<'a, T> |
Copy-on-write query wrapper for efficient link queries |
Point<T> |
Structure representing a single value repeated multiple times |
Hybrid<T> |
Type for distinguishing internal and external link references |
LinksConstants<T> |
Configuration constants including null, any, continue, break, etc. |
Error<'a, T> |
Error type for links operations |
Type Aliases
| Alias | Description |
|---|---|
ReadHandler<'a, T> |
Handler for read operations: &mut dyn FnMut(&[T]) -> Flow |
WriteHandler<'a, T> |
Handler for write operations: &mut dyn FnMut(&[T], &[T]) -> Flow |
Converters
| Type | Description |
|---|---|
AddrToRaw |
Converts link address to raw representation |
RawToAddr |
Converts raw representation back to link address |
Requirements
This crate requires Rust 1.85 or later (stable toolchain, edition 2024).
Dependencies
- beef — Faster and more compact Cow implementation
- funty — Fundamental type unification
- thiserror — Derive macro for error types
Documentation
API documentation is available on docs.rs.
Generated documentation is also deployed to GitHub Pages after each release.
Related Projects
- mem-rs — Memory management for Links Platform
- trees-rs — Tree structures for Links Platform
- Data.Doublets — C# implementation of doublet links
Support
Ask questions at stackoverflow.com/tags/links-platform (or with tag links-platform) to get our free support.
You can also get real-time support on our official Discord server.
License
This project is licensed under the Unlicense — released into the public domain.