Struct feattle::AdminPanel [−][src]
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
P: 'static + Persist + Sync,
F: Feattles<P> + Sync,
[src]
P: 'static + Persist + Sync,
F: Feattles<P> + Sync,
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]
&self
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
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]
&'_ self,
key: &'_ str
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
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]
&'_ self,
key: &'_ str,
value_json: &'_ str
) -> Result<(), RenderError<<P as Persist>::Error>>
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]
&self,
path: &str
) -> Result<RenderedPage, RenderError<<P as Persist>::Error>>
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,
F: Send + Sync,
P: Send,
impl<F, P> Sync for AdminPanel<F, P> where
F: Send + Sync,
P: Sync,
F: Send + Sync,
P: Sync,
impl<F, P> Unpin for AdminPanel<F, P> where
P: Unpin,
P: Unpin,
impl<F, P> !UnwindSafe for AdminPanel<F, P>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,