pub trait ViewSet: Send + Sync {
// Required methods
fn get_basename(&self) -> &str;
fn dispatch<'life0, 'async_trait>(
&'life0 self,
request: Request,
action: Action,
) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn get_lookup_field(&self) -> &str { ... }
fn get_extra_actions(&self) -> Vec<ActionMetadata> { ... }
fn get_extra_action_url_map(&self) -> HashMap<String, String> { ... }
fn get_current_base_url(&self) -> Option<String> { ... }
fn reverse_action(
&self,
_action_name: &str,
_args: &[&str],
) -> Result<String, Error> { ... }
fn get_middleware(&self) -> Option<Arc<dyn ViewSetMiddleware>> { ... }
fn requires_login(&self) -> bool { ... }
fn get_required_permissions(&self) -> Vec<String> { ... }
}Available on non-WebAssembly only.
Expand description
ViewSet trait - similar to Django REST Framework’s ViewSet Uses composition of mixins instead of inheritance
Required Methods§
Sourcefn get_basename(&self) -> &str
fn get_basename(&self) -> &str
Get the basename for URL routing
Provided Methods§
Sourcefn get_lookup_field(&self) -> &str
fn get_lookup_field(&self) -> &str
Get the lookup field for detail routes Defaults to “id” if not overridden
Sourcefn get_extra_actions(&self) -> Vec<ActionMetadata>
fn get_extra_actions(&self) -> Vec<ActionMetadata>
Dispatch request with dependency injection context
Get extra actions defined on this ViewSet
Returns custom actions decorated with #[action] or manually registered
Sourcefn get_extra_action_url_map(&self) -> HashMap<String, String>
fn get_extra_action_url_map(&self) -> HashMap<String, String>
Get URL map for extra actions Returns empty map for uninitialized ViewSets
Sourcefn get_current_base_url(&self) -> Option<String>
fn get_current_base_url(&self) -> Option<String>
Get current base URL (only available after initialization)
Sourcefn reverse_action(
&self,
_action_name: &str,
_args: &[&str],
) -> Result<String, Error>
fn reverse_action( &self, _action_name: &str, _args: &[&str], ) -> Result<String, Error>
Reverse an action name to a URL
Sourcefn get_middleware(&self) -> Option<Arc<dyn ViewSetMiddleware>>
fn get_middleware(&self) -> Option<Arc<dyn ViewSetMiddleware>>
Get middleware for this ViewSet Returns None if no middleware is configured
Sourcefn requires_login(&self) -> bool
fn requires_login(&self) -> bool
Check if login is required for this ViewSet
Sourcefn get_required_permissions(&self) -> Vec<String>
fn get_required_permissions(&self) -> Vec<String>
Get required permissions for this ViewSet