repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/raytrace-parallel/src/pool.rs
examples/raytrace-parallel/src/pool.rs
// Silences warnings from the compiler about Work.func and child_entry_point // being unused when the target is not wasm. #![cfg_attr(not(target_arch = "wasm32"), allow(dead_code))] //! A small module that's intended to provide an example of creating a pool of //! web workers which can be used to execute `rayon`-style...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/performance/src/lib.rs
examples/performance/src/lib.rs
use std::time::{Duration, SystemTime, UNIX_EPOCH}; use wasm_bindgen::prelude::*; // lifted from the `console_log` example #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(a: &str); } macro_rules! console_log { ($($t:tt)*) => (log(&format_args!($($t)*).to_string())) } #[wasm_bi...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/add/src/lib.rs
examples/add/src/lib.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn add(a: u32, b: u32) -> u32 { a + b }
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/canvas/src/lib.rs
examples/canvas/src/lib.rs
use std::f64; use wasm_bindgen::prelude::*; #[wasm_bindgen(start)] fn start() { let document = web_sys::window().unwrap().document().unwrap(); let canvas = document.get_element_by_id("canvas").unwrap(); let canvas: web_sys::HtmlCanvasElement = canvas .dyn_into::<web_sys::HtmlCanvasElement>() ...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/wasm-in-wasm-imports/src/lib.rs
examples/wasm-in-wasm-imports/src/lib.rs
use js_sys::{Function, Map, Object, Reflect, WebAssembly}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::{spawn_local, JsFuture}; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] pub(crate) fn log(a: &str); #[wasm_bindgen(js_namespace = console)] pub(crate) fn error(a: &s...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/char/src/lib.rs
examples/char/src/lib.rs
use wasm_bindgen::prelude::*; // lifted from the `console_log` example #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(s: &str); } #[wasm_bindgen] #[derive(Debug)] pub struct Counter { key: char, count: i32, } #[wasm_bindgen] impl Counter { pub fn new(key: char, count:...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/wasm-in-web-worker/src/lib.rs
examples/wasm-in-web-worker/src/lib.rs
use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen::prelude::*; use web_sys::{console, HtmlElement, HtmlInputElement, MessageEvent, Worker}; /// A number evaluation struct /// /// This struct will be the main object which responds to messages passed to the /// worker. It stores the last number which it was pass...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/dom/src/lib.rs
examples/dom/src/lib.rs
use wasm_bindgen::prelude::*; // Called by our JS entry point to run the example #[wasm_bindgen(start)] fn run() -> Result<(), JsValue> { // Use `web_sys`'s global `window` function to get a handle on the global // window object. let window = web_sys::window().expect("no global `window` exists"); let d...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/julia_set/src/lib.rs
examples/julia_set/src/lib.rs
use std::ops::Add; use wasm_bindgen::prelude::*; use wasm_bindgen::Clamped; use web_sys::{CanvasRenderingContext2d, ImageData}; #[wasm_bindgen] pub fn draw( ctx: &CanvasRenderingContext2d, width: u32, height: u32, real: f64, imaginary: f64, ) -> Result<(), JsValue> { // The real workhorse of th...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/webgl/src/lib.rs
examples/webgl/src/lib.rs
use wasm_bindgen::prelude::*; use web_sys::{WebGl2RenderingContext, WebGlProgram, WebGlShader}; #[wasm_bindgen(start)] fn start() -> Result<(), JsValue> { let document = web_sys::window().unwrap().document().unwrap(); let canvas = document.get_element_by_id("canvas").unwrap(); let canvas: web_sys::HtmlCanv...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/console_log/src/lib.rs
examples/console_log/src/lib.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen(start)] fn run() { bare_bones(); using_a_macro(); using_web_sys(); } // First up let's take a look of binding `console.log` manually, without the // help of `web_sys`. Here we're writing the `#[wasm_bindgen]` annotations // manually ourselves, and the correctne...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/weather_report/src/lib.rs
examples/weather_report/src/lib.rs
extern crate chrono; extern crate reqwest; use chrono::prelude::DateTime; use chrono::Utc; use std::time::{Duration, UNIX_EPOCH}; use gloo::events::EventListener; use json::JsonValue; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::spawn_local; use web_sys::Document; use web_sys::Element; use web_sys::HtmlInp...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/webrtc_datachannel/src/lib.rs
examples/webrtc_datachannel/src/lib.rs
use js_sys::Reflect; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use web_sys::{ MessageEvent, RtcDataChannelEvent, RtcPeerConnection, RtcPeerConnectionIceEvent, RtcSdpType, RtcSessionDescriptionInit, }; macro_rules! console_log { ($($t:tt)*) => (log(&format_args!($($t)*).to_string()))...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/websockets/src/lib.rs
examples/websockets/src/lib.rs
use wasm_bindgen::prelude::*; use web_sys::{ErrorEvent, MessageEvent, WebSocket}; macro_rules! console_log { ($($t:tt)*) => (log(&format_args!($($t)*).to_string())) } #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(s: &str); } #[wasm_bindgen(start)] fn start_websocket() -> Res...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/hello_world/src/lib.rs
examples/hello_world/src/lib.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { fn alert(s: &str); } #[wasm_bindgen] pub fn greet(name: &str) { alert(&format!("Hello, {name}!")); }
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/duck-typed-interfaces/src/lib.rs
examples/duck-typed-interfaces/src/lib.rs
use wasm_bindgen::prelude::*; /// Here is a duck-typed interface for any JavaScript object that has a `quack` /// method. /// /// Note that any attempts to check if an object is a `Quacks` with /// `JsCast::is_instance_of` (i.e. the `instanceof` operator) will fail because /// there is no JS class named `Quacks`. #[wa...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/nodejs_and_deno/src/lib.rs
examples/nodejs_and_deno/src/lib.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "/defined-in-js.js")] extern "C" { type MyClass; #[wasm_bindgen(constructor)] fn new() -> MyClass; #[wasm_bindgen(method, getter)] fn number(this: &MyClass) -> u32; #[wasm_bindgen(method, setter)] fn set_number(this: &MyClass, number: ...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/fetch/src/lib.rs
examples/fetch/src/lib.rs
use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use web_sys::{Request, RequestInit, RequestMode, Response}; #[wasm_bindgen] pub async fn run(repo: String) -> Result<JsValue, JsValue> { let opts = RequestInit::new(); opts.set_method("GET"); opts.set_mode(RequestMode::Cors); let url = ...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
wasm-bindgen/wasm-bindgen
https://github.com/wasm-bindgen/wasm-bindgen/blob/dda4821ee2fbcaa7adc58bc8c385ed8d3627a272/examples/import_js/crate/src/lib.rs
examples/import_js/crate/src/lib.rs
use wasm_bindgen::prelude::*; #[wasm_bindgen(module = "/defined-in-js.js")] extern "C" { fn name() -> String; type MyClass; #[wasm_bindgen(constructor)] fn new() -> MyClass; #[wasm_bindgen(method, getter)] fn number(this: &MyClass) -> u32; #[wasm_bindgen(method, setter)] fn set_numbe...
rust
Apache-2.0
dda4821ee2fbcaa7adc58bc8c385ed8d3627a272
2026-01-04T15:46:52.814516Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/training_sample_generator.rs
src/training_sample_generator.rs
use crate::history::Command; use crate::history::Features; use crate::history::History; use crate::settings::{ResultFilter, Settings}; use crate::training_cache; use rand::seq::IteratorRandom; use std::fs; #[derive(Debug)] pub struct TrainingSampleGenerator { data_set: Vec<(Features, bool)>, } impl TrainingSample...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/history_cleaner.rs
src/history_cleaner.rs
use crate::history::History; use crate::settings::{HistoryFormat, Settings}; use crate::shell_history; use std::env; use std::fs; use std::path::{Path, PathBuf}; pub fn clean(settings: &Settings, history: &History, command: &str) { // Clean up the database. history.delete_command(command); match settings....
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/settings.rs
src/settings.rs
use crate::cli::{Cli, DumpFormat, SortOrder, SubCommand}; use crate::shell_history; use crate::time::parse_timestamp; use clap::Parser; use config::Source; use config::Value; use crossterm::style::Color; use directories_next::{ProjectDirs, UserDirs}; use regex::Regex; use std::collections::HashMap; use std::env; use st...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/node.rs
src/node.rs
use crate::history::Features; use rand::Rng; use std::f64; #[derive(Debug, Copy, Clone, Default)] pub struct Node { pub offset: f64, pub age: f64, pub length: f64, pub exit: f64, pub recent_failure: f64, pub selected_dir: f64, pub dir: f64, pub overlap: f64, pub immediate_overlap: f...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/simplified_command.rs
src/simplified_command.rs
use unicode_segmentation::UnicodeSegmentation; const TRUNCATE_TO_N_TOKENS: u16 = 2; #[derive(Debug)] pub struct SimplifiedCommand { pub original: String, pub result: String, pub truncate: bool, } #[allow(clippy::collapsible_if)] /// The goal of `SimplifiedCommand` is to produce a reduced approximation of...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/lib.rs
src/lib.rs
pub mod cli; pub mod command_input; pub mod dumper; pub mod fake_typer; pub mod fixed_length_grapheme_string; pub mod history; pub mod history_cleaner; pub mod init; pub mod interface; pub mod network; pub mod node; pub mod path_update_helpers; pub mod settings; pub mod shell_history; pub mod simplified_command; pub mo...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/interface.rs
src/interface.rs
use crate::command_input::{CommandInput, Move}; use crate::history::History; use crate::fixed_length_grapheme_string::FixedLengthGraphemeString; use crate::history::Command; use crate::history_cleaner; use crate::settings::{InterfaceView, KeyScheme, ResultFilter}; use crate::settings::{ResultSort, Settings}; use chron...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
true
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/network.rs
src/network.rs
#![allow(clippy::unreadable_literal)] use crate::history::Features; use crate::node::Node; use crate::training_sample_generator::TrainingSampleGenerator; use rand::Rng; #[derive(Debug, Copy, Clone)] pub struct Network { pub final_bias: f64, pub final_weights: [f64; 3], pub final_sum: f64, pub final_out...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/fake_typer.rs
src/fake_typer.rs
#[cfg(not(windows))] use libc; // Should we be using https://docs.rs/libc/0.2.44/libc/fn.ioctl.html instead? #[cfg(not(windows))] unsafe extern "C" { pub fn ioctl(fd: libc::c_int, request: libc::c_ulong, arg: ...) -> libc::c_int; } #[cfg(not(windows))] #[allow(clippy::useless_conversion)] pub fn use_tiocsti(strin...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/fixed_length_grapheme_string.rs
src/fixed_length_grapheme_string.rs
use std::io::Write; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct FixedLengthGraphemeString { pub string: String, pub grapheme_length: u16, pub max_grapheme_length: u16, } impl Write for FixedLengthGraphemeString { fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> ...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/cli.rs
src/cli.rs
use clap::{Parser, Subcommand, ValueEnum}; use regex::Regex; use std::path::PathBuf; /// Fly through your shell history #[derive(Parser)] #[command(author, version)] pub struct Cli { #[command(subcommand)] pub command: SubCommand, /// Debug #[arg(short, long)] pub debug: bool, /// Session ID ...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/time.rs
src/time.rs
use chrono::{DateTime, Local, TimeZone}; #[must_use] pub fn parse_timestamp(s: &str) -> i64 { chrono_systemd_time::parse_timestamp_tz(s, Local) .unwrap_or_else(|err| panic!("McFly error: Failed to parse timestamp ({err})")) .latest() .timestamp() } #[inline] #[must_use] pub fn to_datetime(...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/stats_generator.rs
src/stats_generator.rs
use std::cmp::min; use std::collections::HashMap; use serde::Serialize; use crate::history::History; use crate::settings::Settings; #[derive(Debug)] pub struct StatsGenerator<'a> { history: &'a History, } #[derive(Debug, Clone, Serialize)] struct StatItem { cmd_tpl: String, count: i64, dir: Option<S...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/shell_history.rs
src/shell_history.rs
use crate::settings::HistoryFormat; use regex::Regex; use std::env; use std::fmt; use std::fs; use std::fs::File; use std::fs::OpenOptions; use std::io::Read; use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; fn read_ignoring_utf_errors(pat...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/path_update_helpers.rs
src/path_update_helpers.rs
use crate::settings::pwd; use path_absolutize::Absolutize; use std::path::Path; use unicode_segmentation::UnicodeSegmentation; #[must_use] pub fn normalize_path(incoming_path: &str) -> String { let expanded_path = shellexpand::tilde(incoming_path).to_string(); Path::new(&expanded_path) .absolutize_from...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/init.rs
src/init.rs
use super::settings::InitMode; use std::env; pub struct Init {} impl Init { pub fn new(init_mode: &InitMode) -> Self { match init_mode { InitMode::Bash => { Init::init_bash(); } InitMode::Zsh => { Init::init_zsh(); } ...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/trainer.rs
src/trainer.rs
use crate::history::Features; use crate::history::History; use crate::network::Network; use crate::node::Node; use crate::settings::Settings; use crate::training_sample_generator::TrainingSampleGenerator; #[derive(Debug)] pub struct Trainer<'a> { settings: &'a Settings, history: &'a mut History, } impl<'a> Tr...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/main.rs
src/main.rs
use std::fs; use std::path::PathBuf; use std::time::{SystemTime, UNIX_EPOCH}; use mcfly::dumper::Dumper; use mcfly::fake_typer; use mcfly::history::History; use mcfly::init::Init; use mcfly::interface::Interface; use mcfly::settings::Mode; use mcfly::settings::Settings; use mcfly::shell_history; use mcfly::stats_gener...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/command_input.rs
src/command_input.rs
use std::fmt; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub enum InputCommand { Insert(char), Backspace, Delete, Move(Move), } #[derive(Debug)] pub enum Move { BOL, EOL, BackwardWord, ForwardWord, Backward, Forward, Exact(usize), } #[derive(Debug)] //...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/training_cache.rs
src/training_cache.rs
use crate::history::Features; use csv::Reader; use csv::Writer; use std::fs::File; use std::path::Path; pub fn write(data_set: &[(Features, bool)], cache_path: &Path) { let mut writer = Writer::from_path(cache_path) .unwrap_or_else(|err| panic!("McFly error: Expected to be able to write a CSV ({err})")); ...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/dumper.rs
src/dumper.rs
use std::io::{self, BufWriter, Write}; use crate::cli::DumpFormat; use crate::history::{DumpCommand, History}; use crate::settings::Settings; use crate::time::to_datetime; #[derive(Debug)] pub struct Dumper<'a> { settings: &'a Settings, history: &'a History, } impl<'a> Dumper<'a> { #[inline] pub fn n...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/history/schema.rs
src/history/schema.rs
use crate::simplified_command::SimplifiedCommand; use rusqlite::{Connection, named_params}; use std::io; use std::io::Write; pub const CURRENT_SCHEMA_VERSION: u16 = 3; pub fn first_time_setup(connection: &Connection) { make_schema_versions_table(connection); write_current_schema_version(connection); } pub fn...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/history/history.rs
src/history/history.rs
#![allow(clippy::module_inception)] use crate::cli::SortOrder; use crate::history::{db_extensions, schema}; use crate::network::Network; use crate::path_update_helpers; use crate::settings::{HistoryFormat, ResultFilter, ResultSort, Settings, TimeRange}; use crate::shell_history; use crate::simplified_command::Simplifie...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
true
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/history/mod.rs
src/history/mod.rs
pub use self::history::{Command, DumpCommand, Features, History}; mod db_extensions; mod history; mod schema;
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
cantino/mcfly
https://github.com/cantino/mcfly/blob/b54adb65e1567887fe430188324c09553431eb7c/src/history/db_extensions.rs
src/history/db_extensions.rs
use crate::history::history::Features; use crate::network::Network; use rusqlite::Connection; use rusqlite::functions::FunctionFlags; pub fn add_db_functions(db: &Connection) { let network = Network::default(); db.create_scalar_function( "nn_rank", 10, FunctionFlags::SQLITE_UTF8 | Funct...
rust
MIT
b54adb65e1567887fe430188324c09553431eb7c
2026-01-04T15:50:31.249678Z
false
mgdm/htmlq
https://github.com/mgdm/htmlq/blob/6e31bc814332b2521f0316d0ed9bf0a1c521b6e6/src/link.rs
src/link.rs
use html5ever::local_name; use kuchiki::NodeRef; use url::Url; pub fn rewrite_relative_url(node: &NodeRef, base: &Url) { let Some(elem) = node.as_element() else { return }; if !(local_name!("a") == elem.name.local || local_name!("link") == elem.name.local || local_name!("area") == e...
rust
MIT
6e31bc814332b2521f0316d0ed9bf0a1c521b6e6
2026-01-04T15:50:54.661599Z
false
mgdm/htmlq
https://github.com/mgdm/htmlq/blob/6e31bc814332b2521f0316d0ed9bf0a1c521b6e6/src/pretty_print.rs
src/pretty_print.rs
use html5ever::serialize::AttrRef; use html5ever::serialize::HtmlSerializer; use html5ever::serialize::Serialize; use html5ever::serialize::SerializeOpts; use html5ever::serialize::Serializer; use html5ever::serialize::TraversalScope; use html5ever::QualName; // use kuchiki::traits::TendrilSink; use kuchiki::NodeRef; u...
rust
MIT
6e31bc814332b2521f0316d0ed9bf0a1c521b6e6
2026-01-04T15:50:54.661599Z
false
mgdm/htmlq
https://github.com/mgdm/htmlq/blob/6e31bc814332b2521f0316d0ed9bf0a1c521b6e6/src/main.rs
src/main.rs
extern crate html5ever; extern crate kuchiki; #[macro_use] extern crate lazy_static; mod link; mod pretty_print; use clap::{App, Arg, ArgMatches}; use kuchiki::traits::*; use kuchiki::NodeRef; use std::borrow::BorrowMut; use std::error::Error; use std::fs::File; use std::io; use std::str; use url::Url; #[derive(Deb...
rust
MIT
6e31bc814332b2521f0316d0ed9bf0a1c521b6e6
2026-01-04T15:50:54.661599Z
false
mgdm/htmlq
https://github.com/mgdm/htmlq/blob/6e31bc814332b2521f0316d0ed9bf0a1c521b6e6/tests/cli.rs
tests/cli.rs
use assert_cmd::Command; use predicates::prelude::*; macro_rules! cmd_success_tests { ($($name:ident: $value:expr,)*) => { $( #[test] fn $name(){ let (stdin, args, expected) = $value; Command::cargo_bin("htmlq") .unwrap() .args(args) ...
rust
MIT
6e31bc814332b2521f0316d0ed9bf0a1c521b6e6
2026-01-04T15:50:54.661599Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/build.rs
build.rs
use std::env; use std::fs::read_dir; use std::path::Path; use syntect::dumps::dump_to_file; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSetBuilder; fn build_syntax(dir: &str, out: &str) { let out_dir = env::var_os("OUT_DIR").unwrap(); let mut builder = SyntaxSetBuilder::new(); builder...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/error_reporting.rs
src/error_reporting.rs
use std::process::ExitCode; pub(crate) fn additional_messages(err: &anyhow::Error, native_tls: bool) -> Vec<String> { let mut msgs = Vec::new(); #[cfg(feature = "rustls")] msgs.extend(format_rustls_error(err)); if native_tls && err.root_cause().to_string() == "invalid minimum TLS version for backend"...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/download.rs
src/download.rs
use std::fs::{self, File, OpenOptions}; use std::io::{self, ErrorKind, IsTerminal}; use std::path::{Path, PathBuf}; use std::time::Instant; use crate::content_disposition; use crate::decoder::{decompress, get_compression_type}; use crate::utils::{copy_largebuf, test_pretend_term, HeaderValueExt}; use anyhow::{anyhow, ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/netrc.rs
src/netrc.rs
//! See https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html //! //! And https://github.com/curl/curl/blob/b01165680450364bdc770da3c7ede190872286c8/lib/netrc.c //! //! HTTPie has this behavior: //! //! - Entries must have both a login and a password or they'll be ignored or misbehave. //! //...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/redacted.rs
src/redacted.rs
use std::ffi::OsString; use std::fmt::{self, Debug}; use std::ops::Deref; use std::str::FromStr; /// A String that doesn't show up in Debug representations. /// /// This is important for logging, where we maybe want to avoid outputting /// sensitive data. #[derive(Clone, PartialEq, Eq)] pub struct SecretString(String)...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/nested_json.rs
src/nested_json.rs
//! Insert value into JSON at an arbitrary location specified by a JSON path. //! //! Where JSON path is a string that satisfies the following syntax grammar: //! ``` //! start: root_path path* //! root_path: (literal | index_path | append_path) //! literal: TEXT | NUMBER //! //! path: key_path | index_path | a...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/session.rs
src/session.rs
use std::collections::HashMap; use std::convert::TryInto; use std::ffi::OsString; use std::fs; use std::io::{self, Write}; use std::path::PathBuf; use anyhow::{anyhow, Context, Result}; use reqwest::header::HeaderMap; use serde::{Deserialize, Serialize}; use url::Url; use crate::auth; use crate::utils::{config_dir, t...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/content_disposition.rs
src/content_disposition.rs
use percent_encoding::percent_decode_str; /// Parse filename from Content-Disposition header /// Prioritizes filename* parameter if present, otherwise uses filename parameter pub fn parse_filename_from_content_disposition(content_disposition: &str) -> Option<String> { let parts: Vec<&str> = content_disposition ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/generation.rs
src/generation.rs
use std::io; use clap_complete::Shell; use clap_complete_nushell::Nushell; use crate::cli::Cli; use crate::cli::Generate; const MAN_TEMPLATE: &str = include_str!("../doc/man-template.roff"); pub fn generate(bin_name: &str, generate: Generate) { let mut app = Cli::into_app(); match generate { Genera...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/cli.rs
src/cli.rs
use std::convert::TryFrom; use std::env; use std::ffi::OsString; use std::fmt; use std::fs; use std::io::Write; use std::mem; use std::net::{IpAddr, Ipv6Addr}; use std::path::PathBuf; use std::str::FromStr; use std::time::Duration; use anyhow::{anyhow, Context}; use clap::builder::styling::{AnsiColor, Effects}; use cl...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
true
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/redirect.rs
src/redirect.rs
use anyhow::Result; use reqwest::blocking::{Request, Response}; use reqwest::header::{ HeaderMap, AUTHORIZATION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, COOKIE, LOCATION, PROXY_AUTHORIZATION, TRANSFER_ENCODING, WWW_AUTHENTICATE, }; use reqwest::{Method, StatusCode, Url}; use crate::middleware::{Context...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/middleware.rs
src/middleware.rs
use std::time::{Duration, Instant}; use anyhow::Result; use reqwest::blocking::{Client, Request, Response}; #[derive(Clone)] pub struct ResponseMeta { pub request_duration: Duration, pub content_download_duration: Option<Duration>, } pub trait ResponseExt { fn meta(&self) -> &ResponseMeta; fn meta_mu...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/decoder.rs
src/decoder.rs
use std::cell::Cell; use std::io::{self, Read}; use std::rc::Rc; use std::str::FromStr; use brotli::Decompressor as BrotliDecoder; use flate2::read::{GzDecoder, ZlibDecoder}; use reqwest::header::{HeaderMap, CONTENT_ENCODING, CONTENT_LENGTH, TRANSFER_ENCODING}; use ruzstd::{FrameDecoder, StreamingDecoder as ZstdDecode...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/printer.rs
src/printer.rs
use std::borrow::Cow; use std::io::{self, BufRead, BufReader, Read, Write}; use std::time::Instant; use encoding_rs::Encoding; use encoding_rs_io::DecodeReaderBytesBuilder; use mime::Mime; use reqwest::blocking::{Body, Request, Response}; use reqwest::cookie::CookieStore; use reqwest::header::{HeaderMap, HeaderValue, ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/to_curl.rs
src/to_curl.rs
use std::io::{stderr, stdout, Write}; use anyhow::{anyhow, Context, Result}; use os_display::Quotable; use reqwest::{tls, Method}; use std::ffi::OsString; use crate::cli::{AuthType, Cli, HttpVersion, Verify}; use crate::request_items::{Body, RequestItem, FORM_CONTENT_TYPE, JSON_ACCEPT, JSON_CONTENT_TYPE}; use crate::...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/auth.rs
src/auth.rs
use std::io; use anyhow::Result; use regex_lite::Regex; use reqwest::blocking::{Request, Response}; use reqwest::header::{HeaderValue, AUTHORIZATION, WWW_AUTHENTICATE}; use reqwest::StatusCode; use crate::cli::AuthType; use crate::middleware::{Context, Middleware}; use crate::netrc; use crate::utils::clone_request; ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/utils.rs
src/utils.rs
use std::borrow::Cow; use std::env::var_os; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::str::Utf8Error; use anyhow::Result; use reqwest::blocking::{Request, Response}; use reqwest::header::HeaderValue; use url::Url; pub fn unescape(text: &str, special_chars: &'static str) -> String { let ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/main.rs
src/main.rs
#![allow(clippy::bool_assert_comparison)] mod auth; mod buffer; mod cli; mod content_disposition; mod decoder; mod download; mod error_reporting; mod formatting; mod generation; mod middleware; mod nested_json; mod netrc; mod printer; mod redacted; mod redirect; mod request_items; mod session; mod to_curl; mod utils; m...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/buffer.rs
src/buffer.rs
//! The [`Buffer`] type is responsible for writing the program output, be it //! to a terminal or a pipe or a file. It supports colored output using //! `termcolor`'s `WriteColor` trait. //! //! It's always buffered, so `.flush()` should be called whenever no new //! output is immediately available. That's inconvenient...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/request_items.rs
src/request_items.rs
use std::{ borrow::Cow, collections::HashSet, fs::{self, File}, io, path::{Path, PathBuf}, str::FromStr, }; use anyhow::{anyhow, Result}; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use reqwest::{blocking::multipart, Method}; use crate::cli::BodyType; use crate::nested_json; use...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/vendored/reqwest_cookie_store.rs
src/vendored/reqwest_cookie_store.rs
//! This is a vendored version of reqwest_cookie_store: https://github.com/pfernie/reqwest_cookie_store //! //! It has been slightly modified for xh's use case. It may be unvendored //! if reqwest_cookie_store is updated to use reqwest@0.13 //! //! Copyright 2017 pfernie, see LICENSE-REQWEST_COOKIE_STORE.txt. use std:...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/vendored/mod.rs
src/vendored/mod.rs
pub mod reqwest_cookie_store;
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/formatting/headers.rs
src/formatting/headers.rs
use std::io::Result; use reqwest::{ header::{HeaderMap, HeaderName, HeaderValue}, Method, StatusCode, Version, }; use syntect::highlighting::Theme; use termcolor::WriteColor; use url::Url; use crate::utils::HeaderValueExt; super::palette::palette! { struct HeaderPalette { http_keyword: ["keyword....
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/formatting/palette.rs
src/formatting/palette.rs
//! We used to use syntect for all of our coloring and we still use syntect-compatible //! files to store themes. //! //! But we've started coloring some things manually for better control (and potentially //! for better efficiency). This macro loads colors from themes and exposes them as //! fields on a struct. See [`...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/src/formatting/mod.rs
src/formatting/mod.rs
use std::{ io::{self, Write}, sync::{LazyLock, OnceLock}, }; use syntect::dumps::from_binary; use syntect::easy::HighlightLines; use syntect::highlighting::ThemeSet; use syntect::parsing::SyntaxSet; use syntect::util::LinesWithEndings; use termcolor::WriteColor; use crate::{buffer::Buffer, cli::Theme}; pub(c...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cli.rs
tests/cli.rs
#![allow(clippy::bool_assert_comparison)] mod cases; mod server; use std::collections::{HashMap, HashSet}; use std::fs::{self, File, OpenOptions}; use std::future::Future; use std::io::Write; use std::iter::FromIterator; use std::net::IpAddr; use std::pin::Pin; use std::str::FromStr; use std::time::{Duration, SystemT...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
true
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cases/download.rs
tests/cases/download.rs
use std::{ fs::{self, OpenOptions}, io::Write, }; use predicates::str::contains; use tempfile::tempdir; use crate::prelude::*; #[test] fn download() { let dir = tempdir().unwrap(); let server = server::http(|_req| async move { hyper::Response::builder() .body("file contents\n".int...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cases/mod.rs
tests/cases/mod.rs
mod compress_request_body; mod download; mod logging; mod unix_socket;
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cases/logging.rs
tests/cases/logging.rs
use hyper::header::HeaderValue; use predicates::str::contains; use crate::prelude::*; #[test] fn logs_are_printed_in_debug_mode() { get_command() .arg("--debug") .arg("--offline") .arg(":") .env_remove("RUST_LOG") .assert() .stderr(contains("DEBUG xh] Cli {")) ...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cases/compress_request_body.rs
tests/cases/compress_request_body.rs
use std::{fs::OpenOptions, io::Read as _}; use hyper::header::HeaderValue; use predicates::str::contains; use crate::prelude::*; use std::io::Write; fn zlib_decode(bytes: Vec<u8>) -> std::io::Result<String> { let mut z = flate2::read::ZlibDecoder::new(&bytes[..]); let mut s = String::new(); z.read_to_str...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/cases/unix_socket.rs
tests/cases/unix_socket.rs
#[cfg(unix)] use indoc::indoc; use crate::prelude::*; #[cfg(not(unix))] #[test] fn error_on_unsupported_platform() { use predicates::str::contains; get_command() .arg("--unix-socket=/tmp/missing.sock") .arg(":/index.html") .assert() .failure() .stderr(contains("--unix-...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
ducaale/xh
https://github.com/ducaale/xh/blob/60a8338e35e84eb5352af9dd6b2626f7d54eae5f/tests/server/mod.rs
tests/server/mod.rs
// Copied from https://raw.githubusercontent.com/seanmonstar/reqwest/v0.12.0/tests/support/server.rs // with some slight tweaks use std::convert::Infallible; use std::future::Future; use std::sync::mpsc as std_mpsc; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use http_body_util::Full; use hy...
rust
MIT
60a8338e35e84eb5352af9dd6b2626f7d54eae5f
2026-01-04T15:51:03.526457Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/config.rs
src/config.rs
use std::{ fs::File, io::{BufRead, BufReader}, net::{IpAddr, Ipv4Addr, Ipv6Addr}, path::{Path, PathBuf}, }; use actix_web::http::header::HeaderMap; use anyhow::{Context, Result, anyhow}; #[cfg(feature = "tls")] use rustls_pemfile as pemfile; #[cfg(unix)] use crate::file_utils::get_default_filemode; u...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/errors.rs
src/errors.rs
use std::str::FromStr; use actix_web::{ HttpRequest, HttpResponse, ResponseError, body::{BoxBody, MessageBody}, dev::{ResponseHead, ServiceRequest, ServiceResponse}, http::{StatusCode, header}, middleware::Next, web, }; use thiserror::Error; use crate::{MiniserveConfig, renderer::render_error}...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/consts.rs
src/consts.rs
use fast_qr::ECL; /// The error correction level to use for all QR code generation. pub const QR_EC_LEVEL: ECL = ECL::L; /// The margin size for the SVG QR code on the webpage. pub const SVG_QR_MARGIN: usize = 1;
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/listing.rs
src/listing.rs
#![allow(clippy::format_push_string)] use std::io; use std::path::{Component, Path}; use std::time::SystemTime; use actix_web::{ HttpMessage, HttpRequest, HttpResponse, dev::ServiceResponse, http::Uri, web, web::Query, }; use bytesize::ByteSize; use clap::ValueEnum; use comrak::{Options as ComrakOptions, markdown_...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/renderer.rs
src/renderer.rs
use std::time::SystemTime; use actix_web::http::{StatusCode, Uri}; use chrono::{DateTime, Local}; use chrono_humanize::Humanize; use clap::{ValueEnum, crate_name, crate_version}; use fast_qr::{ QRBuilder, convert::{Builder, svg::SvgBuilder}, qr::QRCodeError, }; use maud::{DOCTYPE, Markup, PreEscaped, html}...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
true
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/archive.rs
src/archive.rs
use std::fs::File; use std::io::{Cursor, Read, Write}; use std::path::{Path, PathBuf}; use libflate::gzip::Encoder; use serde::Deserialize; use strum::{Display, EnumIter, EnumString}; use tar::Builder; use zip::{ZipWriter, write}; use crate::errors::RuntimeError; /// Available archive methods #[derive(Deserialize, C...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/args.rs
src/args.rs
use std::fmt::Display; use std::net::IpAddr; use std::path::PathBuf; use actix_web::http::header::{HeaderMap, HeaderName, HeaderValue}; use clap::{Parser, ValueEnum, ValueHint}; use crate::auth; use crate::listing::{SortingMethod, SortingOrder}; use crate::renderer::ThemeSlug; #[derive(ValueEnum, Clone)] pub enum Me...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/file_utils.rs
src/file_utils.rs
#[cfg(unix)] use rustix::{fs::Mode, process::umask}; use std::{ io, path::{Component, Path, PathBuf}, }; /// Guarantee that the path is relative and cannot traverse back to parent directories /// and optionally prevent traversing hidden directories. /// /// See the unit tests tests::test_sanitize_path* for exa...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/auth.rs
src/auth.rs
use actix_web::{HttpMessage, dev::ServiceRequest, web}; use actix_web_httpauth::extractors::basic::BasicAuth; use sha2::{Digest, Sha256, Sha512}; use crate::errors::RuntimeError; #[derive(Clone, Debug)] /// HTTP Basic authentication parameters pub struct BasicAuthParams { pub username: String, pub password: S...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/webdav_fs.rs
src/webdav_fs.rs
//! Helper types and functions to allow configuring hidden files visibility //! for WebDAV handlers use dav_server::{ davpath::DavPath, fs::{ DavDirEntry, DavFile, DavFileSystem, DavMetaData, FsError as DavFsError, FsFuture as DavFsFuture, FsStream as DavFsStream, OpenOptions as DavOpenOptions,...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/pipe.rs
src/pipe.rs
//! Define an adapter to implement `std::io::Write` on `Sender<Bytes>`. use std::io::{self, Error, ErrorKind, Write}; use actix_web::web::{Bytes, BytesMut}; use futures::channel::mpsc::Sender; use futures::executor::block_on; use futures::sink::SinkExt; /// Adapter to implement the `std::io::Write` trait on a `Sender...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/main.rs
src/main.rs
use std::io::{self, IsTerminal, Write}; use std::net::{IpAddr, SocketAddr, TcpListener}; use std::thread; use std::time::Duration; use actix_files::NamedFile; use actix_web::middleware::from_fn; use actix_web::{ App, HttpRequest, HttpResponse, Responder, dev::{ServiceRequest, ServiceResponse, fn_service}, ...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/src/file_op.rs
src/file_op.rs
//! Handlers for file upload and removal #[cfg(target_family = "unix")] use std::collections::HashSet; use std::io::ErrorKind; #[cfg(target_family = "unix")] use std::os::unix::fs::MetadataExt; use std::path::{Component, Path, PathBuf}; #[cfg(target_family = "unix")] use std::sync::Arc; use actix_web::{HttpReques...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/bind.rs
tests/bind.rs
use std::io::{BufRead, BufReader}; use std::process::{Command, Stdio}; use assert_cmd::{cargo, prelude::*}; use assert_fs::fixture::TempDir; use regex::Regex; use rstest::rstest; mod fixtures; use crate::fixtures::{Error, TestServer, port, server, tmpdir}; #[rstest] #[case(&["-i", "12.123.234.12"])] #[case(&["-i", ...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/qrcode.rs
tests/qrcode.rs
use std::process::{Command, Stdio}; use std::thread::sleep; use std::time::Duration; use assert_cmd::cargo; use assert_fs::TempDir; use rstest::rstest; use select::{document::Document, predicate::Attr}; mod fixtures; use crate::fixtures::{Error, TestServer, port, server, tmpdir}; #[rstest] fn webpage_hides_qrcode_w...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/auth_file.rs
tests/auth_file.rs
use reqwest::{StatusCode, blocking::Client}; use rstest::rstest; use select::{document::Document, predicate::Text}; mod fixtures; use crate::fixtures::{Error, FILES, TestServer, server}; #[rstest] #[case("joe", "123")] #[case("bob", "123")] #[case("bill", "")] fn auth_file_accepts( #[with(&["--auth-file", "tests...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/tls.rs
tests/tls.rs
use assert_cmd::{Command, cargo}; use predicates::str::contains; use reqwest::blocking::ClientBuilder; use rstest::rstest; use select::{document::Document, node::Node}; mod fixtures; use crate::fixtures::{Error, FILES, TestServer, server}; /// Can start the server with TLS and receive encrypted responses. #[rstest] ...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/create_directories.rs
tests/create_directories.rs
use reqwest::blocking::{Client, multipart}; use rstest::rstest; use select::{ document::Document, predicate::{Attr, Text}, }; mod fixtures; use crate::fixtures::{DIRECTORY_SYMLINK, Error, TestServer, server}; /// This should work because the flags for uploading files and creating directories /// are set, and...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/readme.rs
tests/readme.rs
use std::fs::{File, remove_file}; use std::io::Write; use std::path::PathBuf; use rstest::rstest; use select::predicate::Attr; use select::{document::Document, node::Node}; mod fixtures; use fixtures::{DIRECTORIES, Error, FILES, TestServer, server}; fn write_readme_contents(path: PathBuf, filename: &str) -> PathBuf...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false
svenstaro/miniserve
https://github.com/svenstaro/miniserve/blob/308795e98c0347a37870f3c42524bbe21dab9b5c/tests/archive.rs
tests/archive.rs
use reqwest::StatusCode; use rstest::rstest; use select::{document::Document, predicate::Text}; mod fixtures; use crate::fixtures::{Error, TestServer, server}; #[rstest] fn archives_are_disabled(server: TestServer) -> Result<(), Error> { // Ensure the links to the archives are not present let body = reqwest:...
rust
MIT
308795e98c0347a37870f3c42524bbe21dab9b5c
2026-01-04T15:51:38.296723Z
false