Skip to main content

alimentar/serve/
mod.rs

1//! WASM Serve Module - Browser-based data serving and sharing
2//!
3//! This module provides functionality for serving datasets, courses, and other
4//! content types through WASM-based browser applications with optional P2P
5//! sharing.
6//!
7//! # Design Principles
8//!
9//! 1. **Browser-First** - Full functionality in WASM without server
10//!    dependencies
11//! 2. **Plugin Architecture** - Extensible type system for arbitrary content
12//! 3. **Zero-Server Option** - P2P sharing via WebRTC
13//! 4. **Schema-Driven** - YAML/JSON configuration for type definitions
14//!
15//! # Example
16//!
17//! ```ignore
18//! use alimentar::serve::{PluginRegistry, ContentTypeId};
19//!
20//! let registry = PluginRegistry::new();
21//! let plugin = registry.get(&ContentTypeId::dataset()).unwrap();
22//! ```
23
24// Allow builder patterns without must_use (common pattern for fluent APIs)
25#![allow(clippy::return_self_not_must_use)]
26
27mod content;
28mod plugin;
29mod raw_source;
30mod schema;
31
32pub use content::{ContentMetadata, ContentTypeId, ServeableContent, ValidationReport};
33pub use plugin::{ContentPlugin, DatasetPlugin, PluginRegistry, RenderHints};
34pub use raw_source::{RawSource, RawSourceConfig, SourceType};
35pub use schema::{Constraint, ContentSchema, FieldDefinition, FieldType, ValidatorDefinition};
36
37#[cfg(test)]
38mod tests {
39    use super::*;
40
41    #[test]
42    fn test_plugin_registry_creation() {
43        let registry = PluginRegistry::new();
44        assert!(registry.get(&ContentTypeId::dataset()).is_some());
45    }
46
47    #[test]
48    fn test_content_type_id_constants() {
49        assert_eq!(ContentTypeId::dataset().as_str(), "alimentar.dataset");
50        assert_eq!(ContentTypeId::course().as_str(), "assetgen.course");
51        assert_eq!(ContentTypeId::model().as_str(), "aprender.model");
52        assert_eq!(ContentTypeId::registry().as_str(), "alimentar.registry");
53        assert_eq!(ContentTypeId::raw().as_str(), "alimentar.raw");
54    }
55}