salvo.rs
...i64, } #[handler] async fn me(depot: &mut Depot, res: &mut Response) { match depot.jwt_auth_state() { JwtAuthState::Authorized => { let data = depot.jwt_auth_data::<Claims>().unwrap(); res.render(Json(&data.claims)); } JwtAuthState::Unauthorized => res.render(StatusError::unauthorized()), JwtAuthState::Forbidden => res.render(StatusError::forbidden()), } } #[tokio::main] async fn main() { let auth...
Crate
v0.95.2
2026-08-06
docs.rs
...fn compute_something(input: &foo::FooAtom) -> u32 { match *input { foo_atom!("foo") => 1, foo_atom!("bar") => 2, _ => 3, } }
Crate
v0.11.0
2026-08-21
docs.rs
...Support for computing multiple BLAKE2s hashes in parallel, matching the efficiency of BLAKE2sp. See the many module. Example use blake2s_simd::{blake2s, Params}; let expected = "08d6cad88075de8f192db097573d0e829411cd91eb6ec65e8fc16c017edfdb74"; let hash = blake2s(b"foo"); assert_eq!(expected, &hash.to_hex()); let hash = Params::new() .hash_length(16) .key(b"Squeamish Ossifrage") .personal(b...
Crate
v1.0.5
2026-08-20
github.com
...cargo make --profile mainnet build Verifying binary hash To verify that a deployed binary matches the source code, you may want to build it reproducibly and then verify that the SHA256 hash matches that of the deployed binary. The motivation behind this is to prevent malicious code from being deployed...
Crate
v1.2.0
2025-02-06
docs.rs
...Result<Package, _> = serde_path_to_error::deserialize(jd); match result { Ok(_) => panic!("expected a type error"), Err(err) => { let path = err.path().to_string(); assert_eq!(path, "dependencies.serde.version"); } } } License Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state...
Crate
v0.1.20
2025-09-15
crates.io
...If we implemented such without caring about background tasks, then this implementation will not match with the tokio's original implementation. Features Serde Support ( serde feature flag) Worker and NodeJS Support Test Utilities
Crate
v0.4.3
2025-09-01
docs.rs
Implementation of Cookie storage and retrieval Provides an implementation for storing and retrieving Cookie s per the path and domain matching rules specified in RFC6265 . Features preserve_order - uses indexmap::IndexMap in lieu of HashMap internally, so cookies are maintained in insertion/creation order public_suffix - Add support for public...
Crate
v0.22.1
2026-02-16
github.com
...fn macros() { // Existing let vec = js_path("$.values[?match(@, $.regex)]", &json)?; // New let q_ast: JpQuery = ::jsonpath_rust::json_query!($.values[?match(@, $.regex)]); } This allows for query strings to be created infallibly at compile time for applications where query strings will be static strings in source code. Limitations Of Compiled...
Crate
v1.0.8
2026-08-01
crates.io
...let os = os_type::current_platform(); println!("Type: {:?}", os.os_type); println!("Version: {}", os.version); Or to provide different handling on different operating systems: match os_type::current_platform().os_type { os_type::OSType::OSX => { println!("This is probably an apple laptop!"); } os_type::OSType::Ubuntu => { println!("This is running...
Crate
v2.6.0
2022-09-29
docs.rs
...InitState> I => BuilderField<I, T> } // matching on the type-level `InitState` enum by using `InitWit`. // `WITNESS` comes from the `HasTypeWitness` trait match I::WITNESS { // `te: TypeEq<FooInit, Init>` InitWit::InitW(te) => { te.map(HelperFn::NEW) //: TypeEq<BuilderField<I, T>, T> .to_right(maybe_init) } InitWit::UninitW(_) => else_(), } } // Emulates a type...
Crate
v1.15.2
2026-04-14
docs.rs
...ip_address = Ipv6Addr::new(0x2001, 0xdb8, 0xdead, 0xbeef, 0, 0, 0, 0x1); assert_eq!(table.insert(network.clone(), "foo"), None); // Get value for network from table assert_eq!(table.longest_match(ip_address), Some((network, &"foo"))); Minimal required version of Rust compiler is 1.31 (because of ip_network crate).
Crate
v0.2.0
2021-07-12
docs.rs
...by default. .stdout(stdout) // Redirect stdout to `/tmp/daemon.out`. .stderr(stderr) // Redirect stderr to `/tmp/daemon.err`. .privileged_action(|| "Executed before drop privileges"); match daemonize.start() { Ok(_) => println!("Success, daemonized"), Err(e) => eprintln!("Error, {}", e), } } License Licensed under either of Apache License, Version 2.0 ( LICENSE-APACHE or http...
Crate
v0.5.0
2023-02-25
crates.io
...These are situations where matching Rust's ownership and lifetime rules can get tricky. It doesn't make sense to use shared ownership with interior mutability (i.e. Rc<RefCell<T>> or Arc<Mutex<T>> ) nor borrowed references (ie &'a T or &'a mut T ) for structures. The cycles rule...
Crate
v0.2.9
2023-05-22
docs.rs
...It will individually compile each of the source files matching the glob pattern, expect them to fail to compile, and assert that the compiler's error message matches an adjacently named *.stderr file containing the expected output (same file name as the test except with a different extension). If it...
Crate
v1.0.120
2026-08-03
docs.rs
...In those cases you should use a version of xmltree that matches the version of xml you are using: xml version xmltree version 1 0.12 0.8 0.11 0.7 0.8 0.6 0.6 Example See the documentation for some examples: https://docs.rs/xmltree/
Crate
v0.12.0
2025-11-10
docs.rs
...use tokio::time::{Duration, sleep}; #[tokio::main] async fn main() { let (tx, mut rx) = bmrng::channel_with_timeout::<i32, i32>(100, Duration::from_millis(100)); tokio::spawn(async move { match rx.recv().await { Ok((input, mut responder)) => { sleep(Duration::from_millis(200)).await; let res = responder.respond(input * input); assert...
Crate
v0.5.2
2021-08-24
docs.rs
...find_executable_in_path is the most convenient function exported by this crate; given the name of an executable, it will yield the absolute path of the first matching file. use pathsearch::find_executable_in_path; if let Some(exe) = find_executable_in_path("ls") { println!("Found ls at {}", exe...
Crate
v0.2.0
2020-04-11
crates.io
...std")] { let (response_sender, response_receiver) = oneshot::channel(); let request = Request::from("data from sync thread"); processor.send((request, response_sender)).expect("Processor down"); match response_receiver.recv_timeout(Duration::from_secs(1)) { // <- Receive on the oneshot channel Ok(result) => println!("Processor returned {}", result), Err(oneshot::RecvTimeoutError::Timeout) => eprintln!("Processor...
Crate
v0.2.1
2026-02-23
crates.io
...use similar::{ChangeTag, TextDiff}; fn main() { let diff = TextDiff::from_lines( "Hello World\nThis is the second line.\nThis is the third.", "Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more", ); for change in diff.iter_all_changes() { let sign = match change.tag() { ChangeTag::Delete => "-", ChangeTag...
Crate
v3.2.0
2026-08-17
github.com
...This matches the behavior of brotli with a custom dictionary as specified in https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/ What's new in version 4.0.3 Better handling of corrupt brotli files. What's new in version 4.0.2 Better handling of corrupt brotli...
Crate
v5.0.3
2026-06-14