Crate razer

source · []
Expand description

Razer is serverside way to control your website with rust

Example

use razer::event::event_type::Event::JS;
use razer::event::handler::EventHandler;
use razer::listener::Listener;
use razer::send::send;
use razer::Sender;
use razer::Value;

#[derive(Copy)]
pub struct Handler;

impl Clone for Handler {
    fn clone(&self) -> Self {
        *self
    }
}

impl EventHandler for Handler {
    fn load(&self, _event: Value, ctx: &Sender) {
        send(ctx, JS, "alert(\"Hello\")").unwrap();
    }
}

fn main() {
    Listener::new().start(Handler);
}

this will alert “Hello” when ever someone goes onto your site
To add the script all you will have to do is add this to your html

<script src="https://cdn.jsdelivr.net/gh/AMTitan/razer@(your version)/js/razer.min.js"></script>

an example would be

<script src="https://cdn.jsdelivr.net/gh/AMTitan/razer@0.1.4/js/razer.min.js"></script>

Modules

Structs

A representation of the output of the WebSocket connection. Use this to send messages to the other endpoint.

Associates readiness notifications with Evented handles.

Enums

Represents any valid JSON value.