Skip to main content

Crate reinhardt_views

Crate reinhardt_views 

Source
Expand description

§Reinhardt Views

Generic views for Reinhardt framework, inspired by Django’s class-based views.

§Features

  • ListView: Display a list of objects with pagination support
  • DetailView: Display a single object
  • CreateView: Handle object creation
  • UpdateView: Handle object updates
  • DeleteView: Handle object deletion
  • Browsable API: HTML rendering for interactive API exploration
  • Interactive Docs: Swagger UI-like documentation interface
  • Form Generation: Automatic form generation for POST/PUT/PATCH methods
  • Syntax Highlighting: JSON response highlighting with customizable color schemes

§Example

use reinhardt_views::{ListView, DetailView};


// Create a ListView to display paginated users
let list_view = ListView::<User>::new()
    .with_paginate_by(10)
    .with_ordering(vec!["-id".to_string()]);

// Create a DetailView to display a single user
let detail_view = DetailView::<User>::new()
    .with_context_object_name("user");

// Use the views in request handlers

Re-exports§

pub use viewsets::Action;
pub use viewsets::ViewSet;
pub use generic::CreateAPIView;
pub use generic::DestroyAPIView;
pub use generic::ListAPIView;
pub use generic::ListCreateAPIView;
pub use generic::RetrieveAPIView;
pub use generic::RetrieveDestroyAPIView;
pub use generic::RetrieveUpdateAPIView;
pub use generic::RetrieveUpdateDestroyAPIView;
pub use generic::UpdateAPIView;

Modules§

admin
Django Admin Framework
browsable_api
Browsable API rendering
generic
Generic API Views
openapi
OpenAPI schema generation
openapi_inspector
ViewSet inspector for OpenAPI schema generation
viewsets
Reinhardt ViewSets

Macros§

register_viewset_actions
Macro to simplify action registration
viewset_actions
Helper macro to create action mappings

Structs§

DetailView
DetailView for displaying a single object
ListView
ListView for displaying multiple objects

Traits§

MultipleObjectMixin
Trait for views that work with multiple objects
SingleObjectMixin
Trait for views that work with a single object
View
Base trait for all generic views

Type Aliases§

Context
Context data for template rendering