| Crates.io | reinhardt-urls |
| lib.rs | reinhardt-urls |
| version | 0.1.0-alpha.1 |
| created_at | 2026-01-23 06:31:15.339546+00 |
| updated_at | 2026-01-23 06:31:15.339546+00 |
| description | URL routing and proxy utilities for Reinhardt framework |
| homepage | |
| repository | https://github.com/kent8192/reinhardt |
| max_upload_size | |
| id | 2063648 |
| size | 712,656 |
URL routing and proxy utilities for Reinhardt framework
`reinhardt-urls` provides comprehensive URL routing and lazy loading proxy functionality for Reinhardt applications, inspired by Django's URL system.
This crate provides the following modules:
Routers: Automatic URL routing configuration
Routers Macros: Routing-related procedural macros
Proxy: Lazy loading proxy system
Advanced URL Pattern Matching:
path! macroAdd reinhardt to your Cargo.toml:
[dependencies]
reinhardt = { version = "0.1.0-alpha.1", features = ["urls"] }
# For specific sub-features:
# reinhardt = { version = "0.1.0-alpha.1", features = ["urls-routers", "urls-proxy"] }
# Or use a preset:
# reinhardt = { version = "0.1.0-alpha.1", features = ["standard"] } # Recommended
# reinhardt = { version = "0.1.0-alpha.1", features = ["full"] } # All features
Then import URLs features:
use reinhardt::urls::{Router, DefaultRouter, Route};
use reinhardt::urls::routers::{path, re_path, include_routes};
use reinhardt::urls::proxy::{SimpleLazyObject, AssociationProxy};
Note: URLs features are included in the standard and full feature presets.
use reinhardt::urls::{Router, DefaultRouter, Route};
// Create a router
let mut router = DefaultRouter::new();
// Register ViewSet
router.register("users", UserViewSet::new());
// Add custom routes
router.add_route(Route::new("/custom/", custom_handler));
// Match incoming requests
if let Some((handler, params)) = router.match_request(&request) {
handler.handle(request, params).await?;
}
use reinhardt::urls::reverse;
// Reverse URL by name
let url = reverse("user-detail", &[("id", "123")]);
// Returns: /users/123/
// With namespace
let url = reverse("api:v1:user-list", &[]);
// Returns: /api/v1/users/
use reinhardt::urls::proxy::SimpleLazyObject;
// Create lazy object
let lazy_user = SimpleLazyObject::new(|| {
// Expensive initialization
User::from_database(user_id)
});
// Access triggers initialization
let name = lazy_user.name; // Initialization happens here
`reinhardt-urls` is organized into the following modules:
`routers` - URL routing system`routers_macros` - Routing procedural macros`proxy` - Lazy loading proxy utilitiesuse reinhardt::urls::routers::{DefaultRouter, PathPattern};
use reinhardt::urls::proxy::LazyObject;
proxy.rs)AssociationProxy<T, U> - Main proxy type for relationship traversalProxyAccessor trait - Interface for getting/setting proxy targetsProxyTarget enum - Represents scalar or collection proxy resultsScalarValue enum - Type-safe scalar value representation (String, Integer, Float, Boolean, Null)as_string(), as_integer(), as_float(), as_boolean())scalar.rs)ScalarProxy - For one-to-one and many-to-one relationshipsScalarComparison enum - Rich comparison operators (Eq, Ne, Gt, Gte, Lt, Lte, In, NotIn, IsNull, IsNotNull, Like, NotLike)collection.rs)CollectionProxy - For one-to-many and many-to-many relationshipsget_values() - Extract all values from related objectsset_values() - Replace entire collectionappend() - Add single valueremove() - Remove matching valuescontains() - Check for value existencecount() - Get collection sizefilter() - Filter with FilterConditionfilter_by() - Filter with custom predicateCollectionOperations - Wrapper for transformation operations (filter, map, sort, distinct)CollectionAggregations - Wrapper for aggregation operations (sum, avg, min, max)query.rs)FilterOp enum - Filter operations (Eq, Ne, Lt, Le, Gt, Ge, In, NotIn, Contains, StartsWith, EndsWith)FilterCondition - Condition with field, operator, and valueQueryFilter - Container for multiple conditionsmatches() method for evaluating conditions against ScalarValuejoins.rs)JoinConfig - Configuration for eager/lazy loadingLoadingStrategy enum - Eager, Lazy, Select strategiesNestedProxy - Multi-level relationship traversalRelationshipPath - Path representation for relationshipsextract_through_path() - Parse dot-separated pathsfilter_through_path() - Filter path segmentstraverse_and_extract() - Extract from nested proxiestraverse_relationships() - Navigate relationship pathsbuilder.rs)ProxyBuilder<T, U> - Fluent API for proxy constructionrelationship() - Set relationship nameattribute() - Set attribute namecreator() - Set creator functionbuild() - Build with panic on missing configtry_build() - Build returning Optionassociation_proxy() helper functionreflection.rs)Reflectable trait - Core trait for runtime introspection
get_relationship() / get_relationship_mut() - Access relationshipsget_attribute() / set_attribute() - Access attributesget_relationship_attribute() / set_relationship_attribute() - Nested accesshas_relationship() / has_attribute() - Existence checksProxyCollection trait - Unified collection interface
Vec<T>items(), add(), remove(), contains(), len(), clear()AttributeExtractor trait - Scalar value extraction interfacedowncast_relationship() - Type-safe downcastingextract_collection_values() - Bulk value extractionProxyError enum with comprehensive error types:
RelationshipNotFound - Missing relationshipAttributeNotFound - Missing attributeTypeMismatch - Type conversion errorsInvalidConfiguration - Configuration errorsDatabaseError - Database operation errorsSerializationError - Serialization errorsProxyResult<T> type alias for Result with ProxyErrorLicensed under either of Apache License, Version 2.0 or MIT license at your option.