pub trait DataSet<E>: ValueSet{ }Expand description
Entity-aware dataset operations built on top of the ValueSet foundation.
DataSet bridges the gap between raw storage values and typed Rust entities,
providing automatic serialization/deserialization while preserving the flexibility
of the underlying storage backend.
§Type Parameters
E: The entity type that implementsEntitytrait, typically your domain models
§Relationship to ValueSet
While ValueSet works with raw storage values (JSON, CBOR, etc.), DataSet
adds a typed layer that handles conversion between entities and storage format:
Entity <--serde--> Value <--storage--> BackendThis separation allows the same storage backend to efficiently support both raw value operations and typed entity operations as needed.
§Implementation Strategy
Implement the specific capability traits your data source supports:
ReadableDataSetfor read-only sources (CSV files, APIs)InsertableDataSetfor append-only sources (message queues, logs)WritableDataSetfor full CRUD sources (databases, caches)entityDataSetfor change-tracking scenarios (interactive applications)
§Example
use vantage_dataset::dataset::{DataSet, ReadableDataSet, WritableDataSet};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)]
struct User {
name: String,
email: String,
age: u32,
}
// Your storage implementation
struct UserTable;
impl ValueSet for UserTable {
type Id = String;
type Value = serde_json::Value;
}
impl DataSet<User> for UserTable {}
impl ReadableDataSet<User> for UserTable {
async fn list(&self) -> Result<IndexMap<String, User>> {
// Implementation converts storage values to entities
}
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.