[][src]Struct feattle::AdminPanel

pub struct AdminPanel<F, P> { /* fields omitted */ }

The administration panel, agnostic to the choice of web-framework.

This type is designed to be easily integrated with Rust web-frameworks, by providing one method per page and form submission, each returning bytes with their "Content-Type".

Example

use feattle_ui::AdminPanel;
use feattle_core::{feattles, Feattles};
use feattle_core::persist::NoPersistence;
use std::sync::Arc;

feattles! {
    struct MyToggles { a: bool, b: i32 }
}

// `NoPersistence` here is just a mock for the sake of the example
let my_toggles = Arc::new(MyToggles::new(NoPersistence));
let admin_panel = AdminPanel::new(my_toggles, "Project Panda - DEV".to_owned());

let home_content = admin_panel.list_feattles()?;
assert_eq!(home_content.content_type, "text/html; charset=utf-8");
assert!(home_content.content.len() > 0);

Implementations

impl<F, P> AdminPanel<F, P> where
    F: Feattles<P>,
    P: Persist
[src]

pub fn new(feattles: Arc<F>, label: String) -> AdminPanel<F, P>[src]

Create a new UI provider for a given feattles and a user-visible label

pub fn list_feattles(
    &self
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
[src]

Render the page that lists the current feattles values, together with navigation links to modify them. This page is somewhat the "home screen" of the UI.

pub async fn show_feattle(
    &'_ self,
    key: &'_ str
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
[src]

Render the page that shows the current and historical values of a single feattle, together with the form to modify it. The generated form submits to "/feattle/{{ key }}/edit" with the POST method in url-encoded format with a single field called "value_json".

pub async fn edit_feattle(
    &'_ self,
    key: &'_ str,
    value_json: &'_ str
) -> Result<(), RenderError<<P as Persist>::Error>>
[src]

Process a modification of a single feattle, given its key and the JSON representation of its future value. In case of success, the return is empty, so caller should usually redirect the user somewhere after.

pub fn render_public_file(
    &self,
    path: &str
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
[src]

Renders a public file with the given path. The pages include public files like "/public/some/path.js", but this method should be called with only the "some/path.js" part.

Auto Trait Implementations

impl<F, P> !RefUnwindSafe for AdminPanel<F, P>

impl<F, P> Send for AdminPanel<F, P> where
    F: Send + Sync,
    P: Send

impl<F, P> Sync for AdminPanel<F, P> where
    F: Send + Sync,
    P: Sync

impl<F, P> Unpin for AdminPanel<F, P> where
    P: Unpin

impl<F, P> !UnwindSafe for AdminPanel<F, P>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.