6 releases
| 0.1.5 | May 28, 2022 |
|---|---|
| 0.1.4 | May 25, 2022 |
#436 in WebSocket
260KB
5.5K
SLoC
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>
razer
Control your site with rust
Get Started
Add the script
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>
so an example would be
<script src="https://cdn.jsdelivr.net/gh/AMTitan/razer@0.1.4/js/razer.min.js"></script>
Start your server
To start hosting a server go to this url https://crates.io/crates/razer and on the right it says install copy that line and put it in your Cargo.toml
Getting started
You can read the examples I have made and work off of those and the documentation is here https://docs.rs/razer/
Dependencies
~7–9.5MB
~172K SLoC