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 |
|---|---|---|---|---|---|---|---|---|
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/conv_tests.rs | candle-core/tests/conv_tests.rs | use anyhow::Result;
use candle_core::{test_device, test_utils, Device, IndexOp, Tensor};
/* This test is based on the following script.
import torch
torch.manual_seed(4242)
t = torch.randn((1, 4, 5))
w = torch.randn((2, 4, 3))
print(t.flatten())
print(w.flatten())
res = torch.nn.functional.conv1d(t, w)
print(res.flat... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | true |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/pth_tests.rs | candle-core/tests/pth_tests.rs | /// Regression test for pth files not loading on Windows.
#[test]
fn test_pth() {
let tensors = candle_core::pickle::PthTensors::new("tests/test.pt", None).unwrap();
tensors.get("test").unwrap().unwrap();
}
#[test]
fn test_pth_with_key() {
let tensors =
candle_core::pickle::PthTensors::new("tests/t... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/custom_op_tests.rs | candle-core/tests/custom_op_tests.rs | use candle_core::backend::BackendStorage;
use candle_core::cpu_backend;
use candle_core::test_utils::to_vec1_round;
use candle_core::{CpuStorage, CustomOp1, DType, Device, Error, Layout, Result, Shape, Tensor};
fn fwd<T: num_traits::Float>(v: T, alpha: f64) -> T {
if v.is_sign_positive() {
v
} else {
... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/matmul_tests.rs | candle-core/tests/matmul_tests.rs | use candle_core::{test_device, DType, Device, IndexOp, Result, Tensor};
fn matmul(device: &Device) -> Result<()> {
let data = vec![1.0f32, 2.0, 3.0, 4.0];
let a = Tensor::from_slice(&data, (2, 2), device)?;
let data = vec![1.0f32, 2.0, 3.0, 4.0];
let b = Tensor::from_slice(&data, (2, 2), device)?;
... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/layout_tests.rs | candle-core/tests/layout_tests.rs | use candle::{test_device, Device, IndexOp, Result, Tensor};
use candle_core as candle;
fn contiguous(device: &Device) -> Result<()> {
let tensor = Tensor::arange(0u32, 24u32, device)?.reshape((2, 3, 4))?;
assert_eq!(
tensor.to_vec3::<u32>()?,
&[
[[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 1... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/serialization_tests.rs | candle-core/tests/serialization_tests.rs | use candle_core::{DType, Result, Tensor};
struct TmpFile(std::path::PathBuf);
impl TmpFile {
fn create(base: &str) -> TmpFile {
let filename = std::env::temp_dir().join(format!(
"candle-{}-{}-{:?}",
base,
std::process::id(),
std::thread::current().id(),
... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/display_tests.rs | candle-core/tests/display_tests.rs | use anyhow::Result;
use candle_core::{DType, Device::Cpu, Tensor};
#[test]
fn display_scalar() -> Result<()> {
let t = Tensor::new(1234u32, &Cpu)?;
let s = format!("{t}");
assert_eq!(&s, "[1234]\nTensor[[], u32]");
let t = t.to_dtype(DType::F32)?.neg()?;
let s = format!("{}", (&t / 10.0)?);
ass... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/pool_tests.rs | candle-core/tests/pool_tests.rs | use candle_core::{test_device, test_utils, Device, IndexOp, Result, Tensor};
// https://github.com/huggingface/candle/issues/364
fn avg_pool2d(dev: &Device) -> Result<()> {
let data: Vec<f32> = vec![
1., 1., 1., 1., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
];
let t = Tensor::from_vec(data, (... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/bilinear_tests.rs | candle-core/tests/bilinear_tests.rs | use candle_core::{test_device, Device, IndexOp, Result, Tensor};
// ============================================================================
// PyTorch Exact Comparison Tests
// ============================================================================
// These tests compare against exact PyTorch outputs to ensu... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/tests/tensor_tests.rs | candle-core/tests/tensor_tests.rs | use candle_core::{test_device, test_utils, DType, Device, IndexOp, Result, Tensor, D};
use float8::F8E4M3;
fn zeros(device: &Device) -> Result<()> {
let tensor = Tensor::zeros((5, 2), DType::F32, device)?;
let (dim1, dim2) = tensor.dims2()?;
assert_eq!(dim1, 5);
assert_eq!(dim2, 2);
Ok(())
}
fn on... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | true |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/bench_main.rs | candle-core/benches/bench_main.rs | mod benchmarks;
use criterion::criterion_main;
criterion_main!(
benchmarks::affine::benches,
benchmarks::binary::benches,
benchmarks::broadcast::benches,
benchmarks::copy::benches,
benchmarks::conv_transpose2d::benches,
benchmarks::matmul::benches,
benchmarks::qmatmul::benches,
benchma... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/conv_transpose2d.rs | candle-core/benches/benchmarks/conv_transpose2d.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(
x: &Tensor,
k: &Tensor,
padding: usize,
output_padding: usize,
stride: usize,
di... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/unary.rs | candle-core/benches/benchmarks/unary.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run_sqrt(a: &Tensor) {
a.sqrt().unwrap();
}
fn run_unary_benchmark(c: &mut Criterion, device: &Device, d... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/random.rs | candle-core/benches/benchmarks/random.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn rand_uniform(a: &Tensor) {
a.rand_like(-1.0, 123.0).unwrap();
}
fn rand_normal(a: &Tensor) {
a.randn... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/where_cond.rs | candle-core/benches/benchmarks/where_cond.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(a: &Tensor, b: &Tensor, c: &Tensor) {
a.where_cond(b, c).unwrap();
}
const fn create_cond_arr<const ... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/broadcast.rs | candle-core/benches/benchmarks/broadcast.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(w: &Tensor, bias: &Tensor) {
w.broadcast_add(bias).unwrap();
}
fn run_benchmark(c: &mut Criterion, d... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/qmatmul.rs | candle-core/benches/benchmarks/qmatmul.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{
quantized::{self, GgmlDType, QMatMul},
Device, Module, Tensor,
};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(matmul: &QMatMul, x: &Tensor) {
matmul.forward(x).... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/reduce.rs | candle-core/benches/benchmarks/reduce.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use half::{bf16, f16};
use std::hint::black_box;
use std::time::Instant;
fn run_sum(a: &Tensor) {
a.sum_keepdim(2).unwrap();
}
fn run_arg_min(a: &Tensor) {
... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/copy.rs | candle-core/benches/benchmarks/copy.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{Device, Tensor, WithDType};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run_copy_mask_benchmark<D: WithDType>(c: &mut Criterion, device: &Device, name: &str) {
let batch_siz... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/mod.rs | candle-core/benches/benchmarks/mod.rs | pub(crate) mod affine;
pub(crate) mod binary;
pub(crate) mod broadcast;
pub(crate) mod conv_transpose2d;
pub(crate) mod copy;
pub(crate) mod matmul;
pub(crate) mod qmatmul;
pub(crate) mod random;
pub(crate) mod reduce;
pub(crate) mod unary;
pub(crate) mod where_cond;
use candle_core::{Device, Result};
pub(crate) trai... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/matmul.rs | candle-core/benches/benchmarks/matmul.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(a: &Tensor, b: &Tensor) {
a.matmul(&b.t().unwrap()).unwrap();
}
fn run_bench(c: &mut Criterion, devi... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/affine.rs | candle-core/benches/benchmarks/affine.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(a: &Tensor) {
a.affine(12.34, 56.78).unwrap();
}
fn run_affine_benchmark(c: &mut Criterion, device: ... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/benches/benchmarks/binary.rs | candle-core/benches/benchmarks/binary.rs | use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{criterion_group, Criterion, Throughput};
use std::hint::black_box;
use std::time::Instant;
fn run(lhs: &Tensor, rhs: &Tensor) -> Tensor {
lhs.mul(rhs).unwrap()
}
fn run_unary_benchmark(c: &mut Crite... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/examples/cuda_basics.rs | candle-core/examples/cuda_basics.rs | #[cfg(feature = "accelerate")]
extern crate accelerate_src;
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
use anyhow::Result;
use candle_core::{Device, Tensor};
// xs: [1024, 64, 1924], c Tensor[dims 128, 64, 8; f32, cuda:0] Conv1dConfig { padding: 0, stride: 4, dilation: 1, groups: 1 }
fn main() -> Result<()> ... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/examples/metal_basics.rs | candle-core/examples/metal_basics.rs | #[cfg(feature = "accelerate")]
extern crate accelerate_src;
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
use anyhow::Result;
use candle_core::{Device, Tensor};
fn main() -> Result<()> {
// This requires the code to be run with MTL_CAPTURE_ENABLED=1
let device = Device::new_metal(0)?;
let metal_dev... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/examples/basics.rs | candle-core/examples/basics.rs | #[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Result;
use candle_core::{Device, Tensor};
fn main() -> Result<()> {
let a = Tensor::new(&[[0.0f32, 1.0, 2.0], [3.0, 4.0, 5.0]], &Device::Cpu)?;
let b = Tensor::new(&[[88.0f32], [99.0]]... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-core/examples/cuda_sum_benchmark.rs | candle-core/examples/cuda_sum_benchmark.rs | #[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use std::str::FromStr;
use anyhow::Result;
use candle_core::{Device, Tensor};
fn cos_sin(n: usize, device: &Device) -> Result<Tensor> {
let thetas: Vec<_> = (0..n).map(|i| i as f32 / n as f32).collect... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn-v3/build.rs | candle-flash-attn-v3/build.rs | // build.rs
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright (c) 2024 Michael Feil
// adapted from https://github.com/huggingface/candle-flash-attn-v1 , Oliver Dehaene
// adapted further in 2025 by Eric Buehler for candle repo.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http:/... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn-v3/src/lib.rs | candle-flash-attn-v3/src/lib.rs | // SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright (c) 2024 Michael Feil
// 2025 adjusted by Eric Buehler for candle repo.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | true |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn-v3/src/ffi.rs | candle-flash-attn-v3/src/ffi.rs | // SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright (c) 2024 Michael Feil
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copie... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-flash-attn-v3/tests/flash_attn_tests.rs | candle-flash-attn-v3/tests/flash_attn_tests.rs | use anyhow::Result;
use candle_flash_attn_v3;
use candle::{DType, Device, IndexOp, Tensor, D};
use rstest::rstest;
fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> {
let b = 10f32.powi(digits);
let t = t.to_vec3::<f32>()?;
let t = t
.iter()
.map(|t| {
t.ite... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-onnx/build.rs | candle-onnx/build.rs | use std::io::Result;
fn main() -> Result<()> {
prost_build::compile_protos(&["src/onnx.proto3"], &["src/"])?;
Ok(())
}
| rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-onnx/src/lib.rs | candle-onnx/src/lib.rs | use candle::Result;
use prost::Message;
pub mod onnx {
include!(concat!(env!("OUT_DIR"), "/onnx.rs"));
}
pub mod eval;
pub use eval::{dtype, simple_eval};
pub fn read_file<P: AsRef<std::path::Path>>(p: P) -> Result<onnx::ModelProto> {
let buf = std::fs::read(p)?;
onnx::ModelProto::decode(buf.as_slice()).... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | false |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-onnx/src/eval.rs | candle-onnx/src/eval.rs | use crate::onnx::attribute_proto::AttributeType;
use crate::onnx::tensor_proto::DataType;
use crate::onnx::{self, GraphProto};
use candle::Module;
use candle::{bail, DType, Device, IndexOp, Result, Tensor};
use candle_nn::activation::PReLU;
use std::collections::{HashMap, HashSet};
pub type Value = Tensor;
pub fn dty... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | true |
huggingface/candle | https://github.com/huggingface/candle/blob/a4ad7c79666958c38b9afc0e0c3e3499ab8991d8/candle-onnx/tests/ops.rs | candle-onnx/tests/ops.rs | use candle::test_utils::to_vec2_round;
use candle::{DType, Device, NdArray, Result, Tensor};
use candle_onnx::onnx::attribute_proto::AttributeType;
use candle_onnx::onnx::tensor_proto::DataType;
use candle_onnx::onnx::tensor_shape_proto::{dimension, Dimension};
use candle_onnx::onnx::{type_proto, TensorProto, TensorSha... | rust | Apache-2.0 | a4ad7c79666958c38b9afc0e0c3e3499ab8991d8 | 2026-01-04T15:42:50.663313Z | true |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/webdav.rs | src/webdav.rs | use std::future::Future;
use std::io;
use std::net::ToSocketAddrs;
use std::path::PathBuf;
use std::pin::Pin;
use std::task::{Context, Poll};
use anyhow::Result;
use dav_server::{body::Body, DavConfig, DavHandler};
use headers::{authorization::Basic, Authorization, HeaderMapExt};
use hyper::{service::Service, Request,... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/main.rs | src/main.rs | use std::env;
use std::path::PathBuf;
use anyhow::bail;
use clap::{Parser, Subcommand};
use dav_server::{memls::MemLs, DavHandler};
#[cfg(unix)]
use futures_util::stream::StreamExt;
use self_update::cargo_crate_version;
use tracing::{debug, info, warn};
use tracing_subscriber::EnvFilter;
#[cfg(unix)]
use {signal_hook:... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/cache.rs | src/cache.rs | use std::path::Path;
use std::time::Duration;
use moka::future::Cache as MokaCache;
use tracing::debug;
use crate::drive::AliyunFile;
#[derive(Clone)]
pub struct Cache {
inner: MokaCache<String, Vec<AliyunFile>>,
}
impl Cache {
pub fn new(max_capacity: u64, ttl: u64) -> Self {
let inner = MokaCache:... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/vfs.rs | src/vfs.rs | use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::io::{Cursor, SeekFrom, Write};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::Result;
use bytes::{Buf, BufMut, Bytes, BytesMut};
use dashmap::DashMap;
use dav_server::{
davpath::DavPa... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | true |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/drive/model.rs | src/drive/model.rs | use std::collections::HashMap;
use std::ops;
use std::time::SystemTime;
use ::time::{format_description::well_known::Rfc3339, OffsetDateTime};
use serde::{Deserialize, Deserializer, Serialize};
#[derive(Debug, Clone, Deserialize)]
pub struct RefreshTokenResponse {
pub access_token: String,
pub refresh_token: ... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/drive/mod.rs | src/drive/mod.rs | use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use anyhow::{bail, Context, Result};
use bytes::Bytes;
use clap::ValueEnum;
use dav_server::fs::{DavDirEntry, DavMetaData, FsFuture, FsResult};
use futures_util::future::FutureExt;
use reqwest::{
... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/login/model.rs | src/login/model.rs | use std::str::FromStr;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]
pub struct QrCodeRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
pub scopes... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/src/login/mod.rs | src/login/mod.rs | pub mod model;
use crate::drive::DriveConfig;
use crate::login::model::*;
pub struct QrCodeScanner {
client: reqwest::Client,
drive_config: DriveConfig,
}
impl QrCodeScanner {
pub async fn new(drive_config: DriveConfig) -> anyhow::Result<Self> {
let client = reqwest::Client::builder()
... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
messense/aliyundrive-webdav | https://github.com/messense/aliyundrive-webdav/blob/6e8eba62b4e50acf89681e3a67a3a693186dcd05/backend/src/main.rs | backend/src/main.rs | use std::env;
use std::time::Duration;
use axum::{
body::Body,
extract::{Json, State},
http::{HeaderValue, StatusCode},
response::{IntoResponse, Response},
routing::post,
Router,
};
use reqwest::Client;
use serde::Deserialize;
use tokio;
#[derive(Deserialize)]
struct QrCodeRequest {
scopes... | rust | MIT | 6e8eba62b4e50acf89681e3a67a3a693186dcd05 | 2026-01-04T15:44:31.325646Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/build.rs | crates/lib/build.rs | use std::env;
fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let dist_url = if target_os == "windows" {
option_env!("PKGX_DIST_URL").unwrap_or("https://dist.pkgx.dev/v2")
} else {
option_env!("PKGX_DIST_URL").unwrap_or("https://dist.pkgx.dev")
};
let default... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/config.rs | crates/lib/src/config.rs | use std::env;
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
pub struct Config {
pub pantry_dir: PathBuf,
pub pantry_db_file: PathBuf,
pub dist_url: String,
pub pkgx_dir: PathBuf,
}
impl Config {
pub fn new() -> io::Result<Self> {
let pantry_dir = get_pantry_dir()?;
let pant... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/cellar.rs | crates/lib/src/cellar.rs | use crate::config::Config;
use crate::types::{Installation, Package, PackageReq};
use libsemverator::semver::Semver as Version;
use std::error::Error;
use std::path::PathBuf;
use tokio::fs;
pub async fn ls(project: &str, config: &Config) -> Result<Vec<Installation>, Box<dyn Error>> {
let d = config.pkgx_dir.join(p... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/platform_case_aware_env_key.rs | crates/lib/src/platform_case_aware_env_key.rs | #[cfg(windows)]
use std::{
fmt,
hash::{Hash, Hasher},
};
#[cfg(windows)]
#[derive(Clone)]
pub struct CaseInsensitiveKey(pub String);
#[cfg(windows)]
impl PartialEq for CaseInsensitiveKey {
fn eq(&self, other: &Self) -> bool {
self.0.eq_ignore_ascii_case(&other.0)
}
}
#[cfg(windows)]
impl fmt:... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/inventory.rs | crates/lib/src/inventory.rs | use crate::client::build_client;
use crate::config::Config;
use crate::types::{host, Package, PackageReq};
use libsemverator::semver::Semver as Version;
use reqwest::Url;
use std::error::Error;
// Select function to pick a version
pub async fn select(rq: &PackageReq, config: &Config) -> Result<Option<Version>, Box<dyn... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/lib.rs | crates/lib/src/lib.rs | mod cellar;
mod client;
pub mod config;
pub mod env;
pub mod hydrate;
mod install;
pub mod install_multi;
pub mod inventory;
mod pantry;
pub mod pantry_db;
pub mod platform_case_aware_env_key;
pub mod resolve;
pub mod sync;
pub mod types;
pub mod utils;
pub type Version = libsemverator::semver::Semver;
pub type Versio... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/sync.rs | crates/lib/src/sync.rs | use crate::{client::build_client, config::Config, pantry_db};
use async_compression::tokio::bufread::XzDecoder;
use fs2::FileExt;
use futures::TryStreamExt;
use rusqlite::Connection;
use std::{error::Error, fs::OpenOptions, path::PathBuf};
use tokio_tar::Archive;
use tokio_util::compat::FuturesAsyncReadCompatExt;
#[al... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/pantry_db.rs | crates/lib/src/pantry_db.rs | use std::{collections::HashMap, error::Error};
use rusqlite::{params, Connection};
use crate::{config::Config, pantry, types::PackageReq};
pub fn cache(config: &Config, conn: &mut Connection) -> Result<(), Box<dyn Error>> {
conn.execute_batch(
"
PRAGMA synchronous = OFF;
PRAGMA journal_mode = MEM... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/hydrate.rs | crates/lib/src/hydrate.rs | use crate::types::PackageReq;
use libsemverator::range::Range as VersionReq;
use std::collections::{HashMap, HashSet};
use std::error::Error;
#[derive(Clone)]
struct Node {
parent: Option<Box<Node>>,
pkg: PackageReq,
children: HashSet<String>,
}
impl Node {
fn new(pkg: PackageReq, parent: Option<Box<N... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/env.rs | crates/lib/src/env.rs | use std::{
collections::{HashMap, HashSet},
error::Error,
path::PathBuf,
};
#[cfg(unix)]
use std::str::FromStr;
use crate::{
platform_case_aware_env_key::{construct_platform_case_aware_env_key, PlatformCaseAwareEnvKey},
types::Installation,
};
#[cfg(unix)]
pub const SEP: &str = ":";
#[cfg(windows... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/client.rs | crates/lib/src/client.rs | use std::env;
use reqwest::{Client, ClientBuilder};
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
const CERT: &[u8] = include_bytes!("amazon_root_ca1.pem");
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
pub fn build_client() -> Result<Client, Box<dyn std::error::Error>> {
let mut bu... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/install.rs | crates/lib/src/install.rs | use async_compression::tokio::bufread::XzDecoder;
use fs2::FileExt;
use std::{
error::Error,
fs::{self, OpenOptions},
};
use tempfile::tempdir_in;
use tokio::task;
use tokio_tar::Archive;
// Compatibility trait lets us call `compat()` on a futures::io::AsyncRead
// to convert it into a tokio::io::AsyncRead.
us... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/types.rs | crates/lib/src/types.rs | use lazy_static::lazy_static;
use libsemverator::range::Range as VersionReq;
use libsemverator::semver::Semver as Version;
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
use std::error::Error;
use std::fmt;
//TODO regex is probs not most efficient (but do perf tests if you change it)
lazy_static!... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/pantry.rs | crates/lib/src/pantry.rs | use crate::{config::Config, types::PackageReq};
use libsemverator::range::Range as VersionReq;
use serde::Deserialize;
use serde::Deserializer;
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
pub struct PantryEntry {
pub project: String,
pub deps: Vec<PackageReq>,
pub programs: Vec<Stri... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/utils.rs | crates/lib/src/utils.rs | #[cfg(not(windows))]
use std::os::unix::fs::PermissionsExt;
use std::{error::Error, path::Path};
pub async fn find_program(arg: &str, paths: &Vec<String>) -> Result<String, Box<dyn Error>> {
if Path::new(arg).is_absolute() {
return Ok(arg.to_string());
} else if arg.contains("/") {
return Ok(st... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/resolve.rs | crates/lib/src/resolve.rs | use crate::config::Config;
use crate::types::{Installation, Package, PackageReq};
use crate::{cellar, inventory};
use std::error::Error;
#[derive(Debug, Default)]
pub struct Resolution {
/// fully resolved list (includes both installed and pending)
pub pkgs: Vec<Package>,
/// already installed packages
... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/lib/src/install_multi.rs | crates/lib/src/install_multi.rs | use std::error::Error;
use std::sync::Arc;
use crate::install::{install, InstallEvent};
use crate::types::{Installation, Package};
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use crate::config::Config;
pub trait ProgressBarExt {
fn inc(&self, n: u64);
fn inc_length(&self, n: u64);
}
pub a... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/help.rs | crates/cli/src/help.rs | use regex::Regex;
fn dim(input: &str) -> String {
// Placeholder function for "dim" styling
format!("\x1b[2m{}\x1b[0m", input)
}
pub fn usage() -> String {
#[cfg(target_os = "macos")]
let open = "open";
#[cfg(windows)]
let open = "foo";
#[cfg(target_os = "linux")]
let open = "xdg-open"... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/args.rs | crates/cli/src/args.rs | use console::style;
pub enum Mode {
X,
Help,
Version,
Query,
}
pub struct Flags {
pub quiet: bool,
pub silent: bool,
pub json: Option<isize>,
pub version_n_continue: bool,
pub shebang: bool,
pub sync: bool,
pub chdir: Option<String>,
}
pub struct Args {
pub plus: Vec<S... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/execve.rs | crates/cli/src/execve.rs | #[cfg(unix)]
use nix::unistd::execve as nix_execve;
#[cfg(unix)]
use std::ffi::CString;
use libpkgx::platform_case_aware_env_key::PlatformCaseAwareEnvKey;
use std::{collections::HashMap, error::Error};
#[cfg(unix)]
pub fn execve(
cmd: String,
mut args: Vec<String>,
env: HashMap<PlatformCaseAwareEnvKey, St... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/which.rs | crates/cli/src/which.rs | use libpkgx::types::PackageReq;
use rusqlite::Connection;
#[derive(Debug)]
pub enum WhichError {
CmdNotFound(String),
MultipleProjects(String, Vec<String>),
DbError(rusqlite::Error),
}
impl std::fmt::Display for WhichError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/dump.rs | crates/cli/src/dump.rs | use std::{collections::HashMap, path::PathBuf, vec};
use libpkgx::{
env::expand_moustaches, pantry_db,
platform_case_aware_env_key::construct_platform_case_aware_env_key, types::Installation,
};
use serde::Serialize;
use serde_json::json;
pub fn dump(
conn: rusqlite::Connection,
installations: Vec<Ins... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/resolve.rs | crates/cli/src/resolve.rs | use libpkgx::{
config::Config,
hydrate::hydrate,
install_multi::install_multi,
pantry_db, sync,
types::{Installation, PackageReq},
VersionRange,
};
use rusqlite::Connection;
use crate::{
spinner::Spinner,
which::{which, WhichError},
};
pub async fn resolve(
args: &mut [String],
... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/x.rs | crates/cli/src/x.rs | use std::{collections::HashMap, result::Result};
use libpkgx::{
platform_case_aware_env_key::{construct_platform_case_aware_env_key, PlatformCaseAwareEnvKey},
types::{Installation, PackageReq},
utils,
};
use regex::Regex;
use crate::args::Flags;
pub async fn exec(
find_program: bool,
mut args: Ve... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/query.rs | crates/cli/src/query.rs | use std::error::Error;
use libpkgx::pantry_db;
use rusqlite::{params, Connection};
pub fn query(args: &Vec<String>, silent: bool, conn: &Connection) -> Result<(), Box<dyn Error>> {
if args.is_empty() {
let mut stmt = conn.prepare("SELECT program FROM provides")?;
let mut rows = stmt.query(params![... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/main.rs | crates/cli/src/main.rs | mod args;
mod dump;
mod execve;
mod help;
mod query;
mod resolve;
mod spinner;
#[cfg(test)]
mod tests;
mod which;
mod x;
use execve::execve;
use libpkgx::{config::Config, sync};
use spinner::Spinner;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args::Args {
plus,
... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/spinner.rs | crates/cli/src/spinner.rs | use std::{sync::Arc, time::Duration};
use libpkgx::install_multi::ProgressBarExt;
pub struct Spinner {
quiet: bool,
silent: bool,
bar: Option<indicatif::ProgressBar>,
}
impl Spinner {
pub fn new(quiet: bool, silent: bool) -> Spinner {
Self {
bar: None,
quiet,
... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/tests/mod.rs | crates/cli/src/tests/mod.rs | mod main;
| rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
pkgxdev/pkgx | https://github.com/pkgxdev/pkgx/blob/838eecd24a027fa11921dfc0d7e867c30dcf1e78/crates/cli/src/tests/main.rs | crates/cli/src/tests/main.rs | use crate::spinner::{precision, pretty_size};
#[test]
fn test_pretty_size() {
assert_eq!(pretty_size(0), ("0 B".to_string(), 1));
assert_eq!(pretty_size(1), ("1 B".to_string(), 1));
assert_eq!(pretty_size(1024), ("1.00 KiB".to_string(), 1024));
assert_eq!(
pretty_size(1024 * 1024),
("1.... | rust | Apache-2.0 | 838eecd24a027fa11921dfc0d7e867c30dcf1e78 | 2026-01-04T15:44:50.555963Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/db.rs | src/db.rs | use rusqlite::Connection;
use crate::client::{Client, RequestResult};
fn create_db(conn: &Connection) -> Result<usize, rusqlite::Error> {
conn.execute(
"CREATE TABLE IF NOT EXISTS oha (
url TEXT NOT NULL,
start REAL NOT NULL,
start_latency_correction REAL,
e... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/lib.rs | src/lib.rs | use anyhow::Context;
use aws_auth::AwsSignatureConfig;
use bytes::Bytes;
use clap::Parser;
use crossterm::tty::IsTty;
use hickory_resolver::config::{ResolverConfig, ResolverOpts};
use humantime::Duration;
use hyper::{
HeaderMap,
http::{self, header::HeaderName, header::HeaderValue},
};
use printer::{PrintConfig... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | true |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/timescale.rs | src/timescale.rs | use std::{fmt, time::Duration};
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
pub enum TimeScale {
Nanosecond, // 1e-9
Microsecond, // 1e-6
Millisecond, // 1e-3
Second, // 1
TenSeconds, // 10
Minute, // 60
TenMinutes, // 600
Hour, // 3600
}
#[derive(... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/aws_auth.rs | src/aws_auth.rs | use anyhow::Result;
use bytes::Bytes;
use hyper::{
HeaderMap,
header::{self, HeaderName},
};
use thiserror::Error;
use url::Url;
pub struct AwsSignatureConfig {
pub access_key: String,
pub secret_key: String,
pub session_token: Option<String>,
pub service: String,
pub region: String,
}
#[... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/cli.rs | src/cli.rs | use hyper::http::header::{HeaderName, HeaderValue};
use std::str::FromStr;
pub fn parse_header(s: &str) -> Result<(HeaderName, HeaderValue), anyhow::Error> {
let header = s.splitn(2, ':').collect::<Vec<_>>();
anyhow::ensure!(header.len() == 2, anyhow::anyhow!("Parse header"));
let name = HeaderName::from_s... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/pcg64si.rs | src/pcg64si.rs | // https://github.com/imneme/pcg-c
use rand::{RngCore, SeedableRng};
use rand_core::impls;
#[derive(Debug, Copy, Clone)]
#[repr(transparent)]
pub struct Pcg64Si {
state: u64,
}
impl RngCore for Pcg64Si {
fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
}
fn next_u64(&mut self) -> u64 {
... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/client.rs | src/client.rs | use bytes::Bytes;
#[cfg(test)]
use hickory_resolver::config::{ResolverConfig, ResolverOpts};
use http_body_util::{BodyExt, Full};
use hyper::{Method, Request, http};
use hyper_util::rt::{TokioExecutor, TokioIo};
use rand::prelude::*;
use std::{
borrow::Cow,
io::Write,
sync::{
Arc,
atomic::{A... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | true |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/client_h3.rs | src/client_h3.rs | use bytes::Buf;
use bytes::Bytes;
use core::sync::atomic::Ordering;
use http::Request;
use http_body_util::BodyExt;
use hyper::http;
use kanal::AsyncReceiver;
use quinn::default_runtime;
use std::net::SocketAddr;
use std::net::UdpSocket;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Atom... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | true |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/printer.rs | src/printer.rs | use crate::{result_data::ResultData, timescale::TimeScale};
use average::{Max, Min, Variance};
use byte_unit::Byte;
use crossterm::style::{StyledContent, Stylize};
use hyper::http::{self, StatusCode};
use ratatui::crossterm;
use std::{
collections::BTreeMap,
io::Write,
time::{Duration, Instant},
};
#[deriv... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/tls_config.rs | src/tls_config.rs | #[cfg(feature = "rustls")]
pub struct RuslsConfigs {
no_alpn: std::sync::Arc<rustls::ClientConfig>,
alpn_h2: std::sync::Arc<rustls::ClientConfig>,
alpn_h3: std::sync::Arc<rustls::ClientConfig>,
}
#[cfg(feature = "rustls")]
impl RuslsConfigs {
pub fn new(
insecure: bool,
cacert_pem: Opti... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/curl_compat.rs | src/curl_compat.rs | //! Curl compatibility utilities
use std::str::FromStr;
pub struct Form {
pub boundary: String,
pub parts: Vec<FormPart>,
}
pub struct FormPart {
pub name: String,
pub filename: Option<String>,
pub content_type: Option<String>,
pub data: Vec<u8>,
}
impl Form {
pub fn new() -> Self {
... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/monitor.rs | src/monitor.rs | use byte_unit::Byte;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use hyper::http;
use ratatui::{DefaultTerminal, crossterm};
use ratatui::{
layout::{Constraint, Direction, Layout},
style::{Color, Style},
text::{Line, Span},
widgets::{BarChart, Block, Borders, Gauge, Paragraph},
};
us... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/result_data.rs | src/result_data.rs | use std::{
collections::BTreeMap,
time::{Duration, Instant},
};
use average::{Estimate, Max, Mean, Min, concatenate};
use hyper::StatusCode;
use crate::{
client::{ClientError, RequestResult},
histogram::histogram,
};
/// Data container for the results of the all requests
/// When a request is success... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/main.rs | src/main.rs | use clap::Parser;
use oha::{Opts, run};
fn main() {
let num_workers_threads = std::env::var("TOKIO_WORKER_THREADS")
.ok()
.and_then(|s| s.parse().ok())
// Prefer to use physical cores rather than logical one because it's more performant empirically.
.unwrap_or(num_cpus::get_physical... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/request_generator.rs | src/request_generator.rs | use std::borrow::Cow;
use bytes::Bytes;
use http_body_util::Full;
use hyper::http;
use hyper::{HeaderMap, Method, Version};
use rand::Rng;
use rand::seq::IndexedRandom;
use thiserror::Error;
use url::Url;
use crate::aws_auth::{self, AwsSignatureConfig};
use crate::url_generator;
pub struct Proxy {
pub headers: H... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/url_generator.rs | src/url_generator.rs | use std::{borrow::Cow, string::FromUtf8Error};
use rand::prelude::*;
use rand_regex::Regex;
use thiserror::Error;
use url::{ParseError, Url};
#[derive(Clone, Debug)]
pub enum UrlGenerator {
Static(Url),
MultiStatic(Vec<Url>),
Dynamic(Regex),
}
#[derive(Error, Debug)]
pub enum UrlGeneratorError {
#[er... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/src/histogram.rs | src/histogram.rs | pub fn histogram(values: &[f64], bins: usize) -> Vec<(f64, usize)> {
assert!(bins >= 2);
let mut bucket: Vec<usize> = vec![0; bins];
let min = values.iter().collect::<average::Min>().min();
let max = values.iter().collect::<average::Max>().max();
let step = (max - min) / (bins - 1) as f64;
for ... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/tests/tests.rs | tests/tests.rs | use std::{
convert::Infallible,
error::Error as StdError,
fs::File,
future::Future,
io::Write,
net::{Ipv6Addr, SocketAddr},
str::FromStr,
sync::{Arc, OnceLock, atomic::AtomicU16},
};
use axum::{Router, extract::Path, response::Redirect, routing::get};
use bytes::Bytes;
use clap::Parser;... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | true |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/tests/common/mod.rs | tests/common/mod.rs | use std::{net::SocketAddr, sync::Arc};
use bytes::{Buf, Bytes};
use http::{Request, Response};
use kanal::Sender;
use rustls::pki_types::{CertificateDer, PrivateKeyDer};
use h3::{quic::BidiStream, server::RequestStream};
use h3_quinn::quinn::{self, crypto::rustls::QuicServerConfig};
static ALPN: &[u8] = b"h3";
// T... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
hatoo/oha | https://github.com/hatoo/oha/blob/dfe01a1e58bb1d7f4accb0f9b379d035f6856f89/pgo/server/src/main.rs | pgo/server/src/main.rs | use std::net::SocketAddr;
use tokio::net::TcpListener;
use axum::{routing::get, Router};
#[tokio::main]
async fn main() {
// build our application with a route
let app = Router::new()
// `GET /` goes to `root`
.route("/", get(root));
// run our app with hyper
// `axum::Server` is a re... | rust | MIT | dfe01a1e58bb1d7f4accb0f9b379d035f6856f89 | 2026-01-04T15:44:25.967989Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/src/main.rs | src/main.rs | fn main() {
println!("Hello, world!");
}
| rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/no_std/nix/src/main.rs | no_std/nix/src/main.rs | #![no_std]
#![no_main]
extern crate libc;
#[no_mangle]
pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
// Since we are passing a C string the final null character is mandatory.
const HELLO: &'static str = "Hello, world!\n\0";
unsafe {
libc::printf(HELLO.as_ptr() as *const ... | rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/no_std/win/src/main.rs | no_std/win/src/main.rs | #![no_main]
#![no_std]
#![windows_subsystem = "console"]
use core::ffi::c_void;
use core::panic::PanicInfo;
use windows_sys::Win32::System::Console::GetStdHandle;
use windows_sys::Win32::System::Console::WriteConsoleA;
use windows_sys::Win32::System::Console::STD_OUTPUT_HANDLE;
use windows_sys::Win32::System::Threadi... | rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/build_std/src/main.rs | build_std/src/main.rs | fn main() {
println!("Hello, world!");
}
| rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/no_main/nix/src/main.rs | no_main/nix/src/main.rs | #![no_main]
use std::fs::File;
use std::io::Write;
use std::os::unix::io::FromRawFd;
fn stdout() -> File {
unsafe { File::from_raw_fd(1) }
}
#[no_mangle]
pub fn main(_argc: i32, _argv: *const *const u8) {
let mut stdout = stdout();
stdout.write(b"Hello, world!\n").unwrap();
}
| rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
johnthagen/min-sized-rust | https://github.com/johnthagen/min-sized-rust/blob/24233f98d9a8a484302408ed6b5431ed8f720321/no_main/win/src/main.rs | no_main/win/src/main.rs | #![no_main]
use std::fs::File;
use std::io::Write as _;
use std::os::windows::{io::FromRawHandle as _, raw::HANDLE};
#[link(name = "kernel32")]
extern "system" {
pub fn GetStdHandle(nstdhandle: u32) -> HANDLE;
}
pub const STD_OUTPUT_HANDLE: u32 = 4294967285;
fn stdout() -> File {
unsafe { File::from_raw_han... | rust | MIT | 24233f98d9a8a484302408ed6b5431ed8f720321 | 2026-01-04T15:44:57.818982Z | false |
linebender/druid | https://github.com/linebender/druid/blob/b27ea6a618c32f9ea0e8a56822f9487d23401c0d/druid-derive/src/attr.rs | druid-derive/src/attr.rs | // Copyright 2019 the Druid Authors
// SPDX-License-Identifier: Apache-2.0
//! parsing #[druid(attributes)]
use proc_macro2::{Ident, Literal, Span, TokenStream, TokenTree};
use syn::spanned::Spanned;
use syn::{Error, ExprPath, Meta, NestedMeta};
use quote::{quote, quote_spanned};
//show error to tell users of old A... | rust | Apache-2.0 | b27ea6a618c32f9ea0e8a56822f9487d23401c0d | 2026-01-04T15:44:39.941670Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.