docs(actix-router): document Resource trait

This commit is contained in:
Augustin Villetard 2026-02-16 09:45:20 +01:00
parent 15e5c5b4b6
commit 6073462a22
1 changed files with 7 additions and 2 deletions

View File

@ -1,11 +1,16 @@
use crate::Path;
// TODO: this trait is necessary, document it
// see impl Resource for ServiceRequest
/// Abstraction over types that can provide a mutable [`Path`] for routing.
///
/// This trait is used by the router to extract the request path in a uniform way across different
/// request types (e.g., Actix Web's `ServiceRequest`). Implementors return a mutable [`Path`]
/// wrapper so routing can read and potentially normalize/parse the path without requiring the
/// original request type.
pub trait Resource {
/// Type of resource's path returned in `resource_path`.
type Path: ResourcePath;
/// Returns a mutable reference to the path wrapper used by the router.
fn resource_path(&mut self) -> &mut Path<Self::Path>;
}