file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
pkg/logger/logger.go | Go | package logger
import (
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/yorukot/stargo/internal/config"
)
// InitLogger initialize the logger
func InitLogger() {
appEnv := os.Getenv("APP_ENV")
var logger *zap.Logger
if appEnv == string(config.AppEnvDev) {
devConfig := zap.NewDevelopmentConfi... | yorukot/stargo | 3 | Simple and modern Go web API template built with chi router | Go | yorukot | Yorukot | |
pkg/response/response.go | Go | package response
import (
"encoding/json"
"net/http"
)
// ErrorResponse is the response for an error
type ErrorResponse struct {
Message string `json:"message"`
ErrCode string `json:"err_code"`
}
// SuccessResponse is the response for a success
type SuccessResponse struct {
Message string `json:"message"`
Data... | yorukot/stargo | 3 | Simple and modern Go web API template built with chi router | Go | yorukot | Yorukot | |
main.go | Go | package main
import (
"bufio"
"encoding/binary"
"errors"
"fmt"
"os"
"strings"
"unicode/utf8"
"github.com/spf13/cobra"
"golang.org/x/text/unicode/norm"
)
var (
// 8 cores × 8 tones = 64 tokens (fixed codebook)
cores = []string{
"汪",
"嗚",
"嗷",
"汪汪",
"嗚汪",
"嗷汪",
"汪嗚",
"~汪",
}
tones = []stri... | yorukot/woofwoof | 0 | Go | yorukot | Yorukot | ||
example/src/main.rs | Rust | mod generated;
fn main() {
println!("Hello, from the example!");
generated::print();
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/args.rs | Rust | fn main() -> std::io::Result<()> {
std::env::args().for_each(|arg| {
println!("arg: {}", arg);
});
Ok(())
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/dep.rs | Rust | fn main() {
let now = wasi::clocks::wall_clock::now();
println!("The unix time is now: {now:?}")
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/env.rs | Rust | fn main() {
let my_env = std::env::var("MY_ENV_VAR").unwrap();
println!("MY_ENV_VAR={my_env}");
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/generate.rs | Rust | use std::fs;
const FILE: &str = r#"pub fn print() { println!("hello from the generated file"); }""#;
fn main() -> std::io::Result<()> {
// gen the file
Ok(())
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/list.rs | Rust | use std::fs;
fn main() -> std::io::Result<()> {
for entry in fs::read_dir(".")? {
println!("{:?}", entry?);
}
Ok(())
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/module.rs | Rust | //! Calls a function from a local `mod.rs` file
mod shared;
pub fn main() {
println!("hello from the main module");
shared::hello();
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/print.rs | Rust | fn main() {
println!("printed a message from inside a Wasm sandbox!");
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
example/tasks/shared/mod.rs | Rust | pub fn hello() {
println!("hello from the submodule");
}
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
scripts/run.sh | Shell | #!/bin/bash
set -e
export MY_ENV_VAR="my env is this"
PATH=$PATH:$(pwd)/target/debug
cargo build
cd example
cargo task $@
| yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
src/cargo.rs | Rust | use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
/// The cargo.toml representation for tasks
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct CargoToml {
pub package: Package,
}
/// The `package` field inside of Cargo.toml
#[derive(Debug... | yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
src/main.rs | Rust | //! A task runner for Cargo
#![forbid(unsafe_code)]
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::{fs, io};
use clap::Parser;
use fs_extra::dir::CopyOptions;
use wasmtime::{component::Component, Result, *};
use wasmtime_wasi::bindings::Command;
use wasmtime_wasi::{DirPerms, FilePerms, Resou... | yoshuawuyts/cargo-task-wasm | 21 | A sandboxed local task runner for Rust | Rust | yoshuawuyts | Yosh | |
src/dhat.rs | Rust | use serde::Deserialize;
/// A Rust representation of DHAT's JSON file format, which is described in
/// comments in dhat/dh_main.c in Valgrind's source code.
///
/// Building this structure in order to serialize does take up some memory. We
/// could instead stream the JSON output directly to file ourselves. This woul... | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | |
src/folded.rs | Rust | use iter_tools::prelude::*;
use std::fmt::Display;
use crate::{dhat::Dhat, metric::Metric, unit::Unit};
/// A folded stacktrace
#[derive(Debug)]
pub(crate) struct Folded {
pub(crate) lines: Vec<Trace>,
}
impl Folded {
pub(crate) fn from_dhat(dhat: Dhat, metric: Metric, unit: Unit) -> Self {
let lines... | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | |
src/main.rs | Rust | //! Convert dhat JSON output to a collapsed flamegraph format
//!
//! ## Usage
//!
//! ```text
//! Convert dhat JSON output to a flamegraph
//!
//! Usage: dhat-to-flamegraph [OPTIONS] <INPUT>
//!
//! Arguments:
//! <INPUT>
//! The dhat JSON file to process
//!
//! Options:
//! -o, --output <OUTPUT>
//! ... | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | |
src/metric.rs | Rust | /// Which dhat metric to use
#[derive(clap::ValueEnum, Clone, Copy, Default)]
pub(crate) enum Metric {
/// Measure all traces, output total memory usage per trace (default)
#[default]
Total,
/// Measure all traces, output max memory usage per trace
Max,
/// Measure only the remaining traces at p... | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | |
src/unit.rs | Rust | /// Which allocation unit to use
#[derive(clap::ValueEnum, Clone, Copy, Default)]
pub(crate) enum Unit {
/// Measure allocations in bytes (default)
#[default]
Bytes,
/// Measure allocations in blocks, useful to find allocation counts
Blocks,
/// Measure allocations in lifetimes, useful to find s... | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | |
tests/test.rs | Rust | yoshuawuyts/dhat-to-flamegraph | 12 | convert dhat JSON output to a collapsed flamegraph format | Rust | yoshuawuyts | Yosh | ||
src/lib.rs | Rust | //! Experiment with methods on IntoIterator
//!
//! ## Why does this project exist?
//!
//! This project asks the question: what if we used `IntoIterator` everywhere
//! instead of `Iterator`? This becomes relevant for generator blocks, which
//! themselves may contain `!Send` items, but that doesn't mean that the type... | yoshuawuyts/iterate-trait | 7 | experiments with methods on IntoIterator | Rust | yoshuawuyts | Yosh | |
src/map.rs | Rust | //! Helper types for the `map` operation
use super::{Iterate, Iterator};
/// An iterator which maps items from one type to another
#[derive(Debug)]
pub struct Map<I, F> {
pub(crate) iter: I,
f: F,
}
impl<I, F> Map<I, F> {
fn new(iter: I, f: F) -> Map<I, F> {
Map { iter, f }
}
}
/// A type th... | yoshuawuyts/iterate-trait | 7 | experiments with methods on IntoIterator | Rust | yoshuawuyts | Yosh | |
src/lib.rs | Rust | //! A minimal scopeguard implementation
//!
//! # Examples
//!
//! ```rust
//! # #![allow(unused)]
//! # use mini_scopeguard::Guard;
//! {
//! // Create a new guard around a string that will
//! // print its value when dropped.
//! let s = String::from("Chashu likes tuna");
//! let mut s = Guard::new(s,... | yoshuawuyts/mini-scopeguard | 1 | A minimal scopeguard implementation | Rust | yoshuawuyts | Yosh | |
examples/basic.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Box<Self> {
Box::new(Self { age })
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {
let mut cat = unsafe { Cat::placing_uninit_new() };
unsafe { Cat::placing_init... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/fn_kind.rs | Rust | use crate::utils::path_ident;
use syn::{FnArg, Receiver, ReturnType, Signature};
/// What kind of function are we operating on?
#[derive(Debug)]
pub(crate) enum FunctionKind {
/// A static method with no self-ty
Static,
/// A static constructor with a return type of `Self`
Constructor(HeapTy),
/// ... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/mod.rs | Rust | use proc_macro::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, ImplItem, ImplItemFn, ItemImpl};
use crate::utils::{
create_maybe_generics, has_placing_attr, set_path_generics, strip_placing_attr,
};
mod fn_kind;
mod moving;
mod placing;
/// Process an impl block that carries the `#[placing]` notatio... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/moving.rs | Rust | use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{spanned::Spanned, ImplItemFn};
use super::ImplFns;
/// Rewrite a non-`#[placing]` statement to create the inner type instead
pub(crate) fn rewrite_moving_constructor(
output: &mut ImplFns,
mut f: ImplItemFn,
ident: &syn::Ident,
) -> ... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/placing/inline.rs | Rust | use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{spanned::Spanned, ImplItemFn};
use super::ImplFns;
pub(crate) fn inline_constructor(output: &mut ImplFns, f: ImplItemFn) -> Result<(), TokenStream> {
let fn_ident = f.sig.ident.clone();
// Create the new uninit constructor
let syn::... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/placing/mod.rs | Rust | use proc_macro::TokenStream;
use syn::{spanned::Spanned, ImplItemFn};
use crate::utils;
use super::ImplFns;
mod inline;
mod pointer;
/// Rewrite a `#[placing]` statement to create the inner type instead
pub(crate) fn rewrite_placing_constructor(
output: &mut ImplFns,
f: ImplItemFn,
ident: &syn::Ident,
)... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/inherent/placing/pointer.rs | Rust | use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{spanned::Spanned, ImplItemFn, Signature};
use super::ImplFns;
use crate::utils::{expr_path_ident, PointerKind};
pub(crate) fn pointer_constructor(
output: &mut ImplFns,
f: ImplItemFn,
kind: PointerKind,
) -> Result<(), TokenStream> {... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/lib.rs | Rust | //! A prototype notation for referentially stable constructors
//!
//! ## Tasks
//!
//! - [ ] support structs
//! - [ ] support enums
//! - [ ] support traits
//! - [ ] support custom drop impls
#![forbid(unsafe_code)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs)]
use proc_macro::T... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/strukt.rs | Rust | use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::ItemStruct;
use crate::utils::create_maybe_generics;
/// Process an impl block that carries the `#[placing]` notation
pub(crate) fn process_struct(item: ItemStruct) -> TokenStream {
// We need all the impl components to later recreate it
... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/utils.rs | Rust | use proc_macro::TokenStream;
use quote::{quote, ToTokens};
use syn::{spanned::Spanned, Attribute, ExprPath, GenericParam, Path, Token};
/// Add the const param to the trait definition
pub(crate) fn create_maybe_generics(generics: &syn::Generics) -> syn::Generics {
let mut outer_generics = generics.clone();
let... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0001-invalid-item-kind.rs | Rust | #[placing::placing]
union Cat {
age: u8,
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0002-trait-impls-unsupported.rs | Rust | struct Cat {
age: u8,
}
trait Meow {}
#[placing::placing]
impl Meow for Cat {}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0003-invalid-impl-target.rs | Rust | trait Meow {
type Sound;
}
#[placing::placing]
impl [Cat] {}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0004-invalid-attr.rs | Rust | #[placing::placing]
struct Cat;
#[placing::placing]
impl Cat {
#[placing(invalid)]
fn list(&self) -> Self {
todo!()
}
#[placing = "invalid"]
fn path(&self) -> Self {
todo!()
}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0005-empty-constructor-body.rs | Rust | #[placing::placing]
struct Cat;
#[placing::placing]
impl Cat {
#[placing]
fn new() -> Self {}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0006-invalid-constructor-body-non-expr.rs | Rust | #[placing::placing]
struct Cat;
#[placing::placing]
impl Cat {
#[placing]
fn new() -> Self {
todo!()
}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0006-invalid-constructor-body-non-struct.rs | Rust | #[placing::placing]
struct Cat;
#[placing::placing]
impl Cat {
#[placing]
fn new() -> Self {
{
Self {}
}
}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0007-invalid-placing-target.rs | Rust | #[placing::placing]
struct Cat;
#[placing::placing]
impl Cat {
#[placing]
fn new(&self) {}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-fail/E0008-invalid-pointer-constructor.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Box<Self> {
Box::new()
}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/allowed-impl-block.rs | Rust | #[placing::placing]
struct Cat {}
#[placing::placing]
impl Cat {}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/allowed-struct.rs | Rust | #[placing::placing]
struct Cat {}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/generics-struct.rs | Rust | #[placing::placing]
struct Cat<K, J, const N: usize>
where
J: Send,
{
k: K,
j: J,
foo: [u8; N],
}
#[placing::placing]
impl<K, J, const N: usize> Cat<K, J, N> where J: Send {}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/placing-body.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Self {
let age = age * 2;
Self { age }
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {
let mut cat = unsafe { Cat::placing_uninit_new() };
unsafe { cat.p... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/placing-box.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Box<Self> {
Box::new(Self { age })
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {
let mut cat = unsafe { Cat::placing_uninit_new() };
unsafe { cat.placing_init_... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/placing-builds.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Self {
Self { age }
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/placing-runs.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
#[placing]
fn new(age: u8) -> Self {
Self { age }
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {
let mut cat = unsafe { Cat::placing_uninit_new() };
unsafe { cat.placing_init_new(12) };
... | yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/preserves-associated-items.rs | Rust | #[placing::placing]
struct Cat {}
#[placing::placing]
impl Cat {
const NAME: &str = "chashu";
}
fn main() {
assert_eq!(Cat::NAME, "chashu");
}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui-pass/regular-constructor.rs | Rust | #[placing::placing]
struct Cat {
age: u8,
}
#[placing::placing]
impl Cat {
fn new(age: u8) -> Self {
Self { age }
}
fn age(&self) -> &u8 {
&self.age
}
}
fn main() {
let cat = Cat::new(12);
assert_eq!(cat.age(), &12);
}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
tests/ui.rs | Rust | // set `TRYBUILD=overwrite` to update the stdout output
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui-fail/*.rs");
t.pass("tests/ui-pass/*.rs");
}
| yoshuawuyts/placing | 17 | A prototype notation for referentially stable constructors | Rust | yoshuawuyts | Yosh | |
src/future.rs | Rust | use std::os::fd::RawFd;
#[derive(Debug)]
pub enum Interest {
Read,
Close,
}
#[derive(Debug)]
pub enum Waitable {
/// Registered file descriptor.
Fd(RawFd, Interest),
}
pub trait Future {
type Output;
fn poll(&mut self, ready: &[Waitable]) -> impl Iterator<Item = Waitable>;
fn take(&mut se... | yoshuawuyts/playground-future-2.0 | 2 | Playing with a different formulation of Future | Rust | yoshuawuyts | Yosh | |
src/main.rs | Rust | //! shout out noah kennedy:
//! https://gist.github.com/yoshuawuyts/c74b0b344f62133664f36d8192367b97
#![cfg(target_os = "macos")]
use std::io::{self, Read, Write};
use std::net::{TcpListener, TcpStream};
use std::thread;
use std::time::Duration;
mod future;
mod runtime;
mod tcp;
use runtime::Poller;
use tcp::AsyncT... | yoshuawuyts/playground-future-2.0 | 2 | Playing with a different formulation of Future | Rust | yoshuawuyts | Yosh | |
src/runtime.rs | Rust | use rustix::event::kqueue;
use std::io;
use std::os::fd::{AsFd, OwnedFd, RawFd};
use std::time::Duration;
use crate::future::{Future, Interest, IntoFuture, Waitable};
pub struct Poller {
queue: OwnedFd,
events: Vec<kqueue::Event>,
}
impl Poller {
pub fn open() -> io::Result<Self> {
Ok(Self {
... | yoshuawuyts/playground-future-2.0 | 2 | Playing with a different formulation of Future | Rust | yoshuawuyts | Yosh | |
src/tcp.rs | Rust | use std::io::{self, Read};
use std::net::{TcpStream, ToSocketAddrs};
use std::os::fd::{AsRawFd, RawFd};
use crate::future::{Future, Interest, Waitable};
pub struct AsyncTcpStream(pub TcpStream);
impl AsRawFd for AsyncTcpStream {
fn as_raw_fd(&self) -> RawFd {
self.0.as_raw_fd()
}
}
impl AsyncTcpStrea... | yoshuawuyts/playground-future-2.0 | 2 | Playing with a different formulation of Future | Rust | yoshuawuyts | Yosh | |
examples/example.rs | Rust | use read_dir_all::read_dir_all;
use std::{env, io};
fn main() -> io::Result<()> {
let path = env::current_dir()?;
for entry in read_dir_all(path)? {
println!("{}", entry?.path().display());
}
Ok(())
}
| yoshuawuyts/read-dir-all | 1 | Rust | yoshuawuyts | Yosh | ||
src/lib.rs | Rust | //! simple, recursive readdir
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, future_incompatible, unreachable_pub)]
use std::fs::{self, DirEntry, ReadDir};
use std::io;
use std::path::Path;
/// Recursively iterate over all entries in a direc... | yoshuawuyts/read-dir-all | 1 | Rust | yoshuawuyts | Yosh | ||
crates/cli/src/inspect/mod.rs | Rust | use bytesize::ByteSize;
use std::fs;
use std::io::{Stdout, Write};
use std::path::PathBuf;
use anyhow::Result;
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
use comfy_table::presets::UTF8_FULL;
use comfy_table::{CellAlignment, ContentArrangement, Table};
use wasm_metadata::{Metadata, Payload};
/// Read metadata (mo... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/lib.rs | Rust | //! Wasm CLI library
//!
//! This module exports types for testing purposes.
#![allow(unreachable_pub)]
/// TUI module for terminal user interface
pub mod tui;
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/local/mod.rs | Rust | use std::path::PathBuf;
use anyhow::Result;
use comfy_table::{Table, modifiers::UTF8_ROUND_CORNERS, presets::UTF8_FULL};
use wasm_detector::WasmDetector;
/// Detect and manage local WASM files
#[derive(clap::Parser)]
pub(crate) enum Opts {
/// List local WASM files in the current directory
List(ListOpts),
}
... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/main.rs | Rust | //! Wasm CLI command
//!
mod inspect;
mod local;
mod package;
mod self_;
mod tui;
use std::io::IsTerminal;
use clap::{ColorChoice, CommandFactory, Parser};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
/// When to use colored output.
... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/package/mod.rs | Rust | use anyhow::Result;
use wasm_package_manager::{InsertResult, Manager, Reference};
/// Package, push, and pull Wasm Components
#[derive(clap::Parser)]
pub(crate) enum Opts {
/// Fetch OCI metadata for a component
Show,
/// Pull a component from the registry
Pull(PullOpts),
Push,
/// List all ava... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/self_/mod.rs | Rust | use anyhow::Result;
use wasm_package_manager::{Manager, format_size};
/// Configure the `wasm(1)` tool, generate completions, & manage state
#[derive(clap::Parser)]
pub(crate) enum Opts {
/// Print diagnostics about the local state
State,
}
impl Opts {
pub(crate) async fn run(&self) -> Result<()> {
... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/app.rs | Rust | use ratatui::{
crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers},
prelude::*,
widgets::{Block, Clear, Paragraph},
};
use std::time::Duration;
use tokio::sync::mpsc;
use wasm_package_manager::{ImageEntry, InsertResult, KnownPackage, StateInfo, WitInterface};
use super::components::{TabBar... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/components/mod.rs | Rust | mod tab_bar;
pub use tab_bar::{TabBar, TabItem};
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/components/tab_bar.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, Tabs},
};
/// A trait for items that can be displayed in a tab bar.
pub trait TabItem: Copy + PartialEq + 'static {
/// Returns all tab items in order.
fn all() -> &'static [Self];
/// Returns the display title for this tab.
fn title(&self) -> &'stat... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/mod.rs | Rust | #![allow(unreachable_pub)]
mod app;
/// TUI components
pub mod components;
/// TUI views
pub mod views;
use app::App;
use tokio::sync::mpsc;
use wasm_package_manager::{
ImageEntry, InsertResult, KnownPackage, Manager, Reference, StateInfo, WitInterface,
};
/// Events sent from the TUI to the Manager
#[derive(Deb... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/interfaces.rs | Rust | use ratatui::{
prelude::*,
widgets::{
Block, Paragraph, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, StatefulWidget,
Table, TableState, Widget, Wrap,
},
};
use wasm_package_manager::WitInterface;
/// State for the interfaces view
#[derive(Debug, Default)]
pub struct InterfacesViewS... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/known_package_detail.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, Borders, Paragraph, Widget, Wrap},
};
use wasm_package_manager::KnownPackage;
/// View for displaying details of a known package (from search results).
#[derive(Debug)]
#[allow(dead_code)]
pub struct KnownPackageDetailView<'a> {
package: &'a KnownPackage,
}
impl... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/local.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, List, ListItem, Paragraph, Widget},
};
use wasm_detector::WasmEntry;
/// View for the Local tab
#[derive(Debug)]
pub struct LocalView<'a> {
wasm_files: &'a [WasmEntry],
}
impl<'a> LocalView<'a> {
/// Create a new LocalView with the given WASM files
#[mus... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/mod.rs | Rust | mod interfaces;
/// Known package detail view module
pub mod known_package_detail;
mod local;
mod package_detail;
/// Packages view module
pub mod packages;
mod search;
mod settings;
pub use interfaces::{InterfacesView, InterfacesViewState};
#[allow(unused_imports)]
pub use known_package_detail::KnownPackageDetailView... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/package_detail.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, Borders, Paragraph, Widget, Wrap},
};
use wasm_package_manager::ImageEntry;
/// View for displaying details of an installed package
#[derive(Debug)]
pub struct PackageDetailView<'a> {
package: &'a ImageEntry,
}
impl<'a> PackageDetailView<'a> {
/// Creates a ... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/packages.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, Cell, Paragraph, Row, StatefulWidget, Table, TableState, Widget},
};
use wasm_package_manager::ImageEntry;
use super::format_size;
/// State for the packages list view
#[derive(Debug, Default)]
pub struct PackagesViewState {
/// Table selection state
pub tab... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/search.rs | Rust | use ratatui::{
prelude::*,
widgets::{Block, Cell, Paragraph, Row, StatefulWidget, Table, TableState, Widget},
};
use wasm_package_manager::KnownPackage;
/// State for the search view
#[derive(Debug, Default)]
pub struct SearchViewState {
/// Table selection state
pub table_state: TableState,
/// Cu... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/src/tui/views/settings.rs | Rust | use ratatui::{
prelude::*,
widgets::{Cell, Paragraph, Row, Table, Widget},
};
use wasm_package_manager::StateInfo;
/// View for displaying settings and state information
#[derive(Debug)]
pub struct SettingsView<'a> {
state_info: Option<&'a StateInfo>,
}
impl<'a> SettingsView<'a> {
/// Creates a new se... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/tests/snapshot.rs | Rust | //! Snapshot tests for TUI views using the `insta` crate.
//!
//! These tests render each view to a buffer and snapshot the result to ensure
//! consistent rendering across changes.
//!
//! # Running Snapshot Tests
//!
//! Run tests with: `cargo test --package wasm`
//!
//! # Updating Snapshots
//!
//! When views chang... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/cli/tests/test.rs | Rust | //! Tests for the wasm CLI
//!
//! This module contains integration tests for CLI commands.
//! Use `cargo test --package wasm --test test` to run these tests.
//!
//! # CLI Help Screen Tests
//!
//! These tests verify that CLI help screens remain consistent using snapshot testing.
//! When commands change, update snap... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/manifest/src/lib.rs | Rust | //! Manifest and lockfile format types for WebAssembly packages.
//!
//! This crate provides types for parsing and serializing WASM package manifests
//! (`wasm.toml`) and lockfiles (`wasm.lock`).
//!
//! # Example: Parsing a Manifest
//!
//! ```rust
//! use wasm_manifest::Manifest;
//!
//! let toml = r#"
//! [dependen... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/manifest/src/lockfile.rs | Rust | //! Types for the WASM lockfile (`wasm.lock`).
use serde::{Deserialize, Serialize};
/// The root lockfile structure for a WASM package.
///
/// The lockfile (`deps/wasm.lock`) is auto-generated and tracks resolved dependencies
/// with their exact versions and content digests.
///
/// # Example
///
/// ```toml
/// ve... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/manifest/src/manifest.rs | Rust | //! Types for the WASM manifest file (`wasm.toml`).
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// The root manifest structure for a WASM package.
///
/// The manifest file (`deps/wasm.toml`) defines dependencies for a WASM package.
///
/// # Example
///
/// ```toml
/// [dependencies]
/// "wa... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/manifest/src/validation.rs | Rust | //! Validation functions for manifest and lockfile consistency.
use crate::{Lockfile, Manifest};
use std::collections::HashSet;
/// Error type for validation failures.
#[derive(Debug, Clone, PartialEq, Eq)]
#[must_use]
pub enum ValidationError {
/// A package in the lockfile is not present in the manifest.
Mi... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/lib.rs | Rust | //! A package manager for WebAssembly components.
//!
//! This crate provides functionality to pull, store, and manage WebAssembly
//! component packages from OCI registries.
mod manager;
mod network;
mod storage;
pub use manager::Manager;
pub use oci_client::Reference;
pub use storage::{ImageEntry, InsertResult, Kno... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/manager/mod.rs | Rust | use oci_client::Reference;
use crate::network::Client;
use crate::storage::{ImageEntry, InsertResult, KnownPackage, StateInfo, Store, WitInterface};
/// A cache on disk
#[derive(Debug)]
pub struct Manager {
client: Client,
store: Store,
offline: bool,
}
impl Manager {
/// Create a new store at a loca... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/network/client.rs | Rust | use docker_credential::DockerCredential;
use oci_client::Reference;
use oci_client::client::{ClientConfig, ClientProtocol, ImageData};
use oci_client::secrets::RegistryAuth;
use oci_wasm::WasmClient;
pub(crate) struct Client {
inner: WasmClient,
}
impl std::fmt::Debug for Client {
fn fmt(&self, f: &mut std::f... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/network/mod.rs | Rust | mod client;
pub(crate) use client::Client;
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/config.rs | Rust | use anyhow::Context;
use std::env;
use std::path::{Path, PathBuf};
use super::models::Migrations;
/// Information about the current state of the package manager.
#[derive(Debug, Clone)]
pub struct StateInfo {
/// Path to the current executable
executable: PathBuf,
/// Path to the data storage directory
... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/00_migrations.sql | SQL | CREATE TABLE IF NOT EXISTS migrations (
id INTEGER PRIMARY KEY,
version INTEGER NOT NULL UNIQUE,
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
);
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/01_init.sql | SQL | -- DROP TABLE IF EXISTS image;
CREATE TABLE IF NOT EXISTS image (
id INTEGER PRIMARY KEY,
ref_registry TEXT NOT NULL,
ref_repository TEXT NOT NULL,
ref_mirror_registry TEXT,
ref_tag TEXT,
ref_digest TEXT,
manifest TEXT NOT NULL
);
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/02_known_packages.sql | SQL | -- Table for known packages that persists even after local deletion
-- This tracks packages the user has seen/searched for
CREATE TABLE IF NOT EXISTS known_package (
id INTEGER PRIMARY KEY,
registry TEXT NOT NULL,
repository TEXT NOT NULL,
description TEXT,
last_seen_at TEXT NOT NULL DEFAULT (dateti... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/03_known_package_tags.sql | SQL | -- Table for tags associated with known packages
CREATE TABLE IF NOT EXISTS known_package_tag (
id INTEGER PRIMARY KEY,
known_package_id INTEGER NOT NULL,
tag TEXT NOT NULL,
last_seen_at TEXT NOT NULL DEFAULT (datetime('now')),
created_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (kno... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/04_image_size.sql | SQL | -- Add size_on_disk column to track the storage size of each image
ALTER TABLE image ADD COLUMN size_on_disk INTEGER NOT NULL DEFAULT 0;
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/05_tag_type.sql | SQL | -- Add tag_type column to distinguish regular tags from signatures and attestations
ALTER TABLE known_package_tag ADD COLUMN tag_type TEXT NOT NULL DEFAULT 'release';
-- Update existing signature and attestation tags
UPDATE known_package_tag SET tag_type = 'signature' WHERE tag LIKE '%.sig';
UPDATE known_package_tag S... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/06_wit_interface.sql | SQL | -- WIT Interface storage tables
-- Store extracted WIT interface text for each component
CREATE TABLE IF NOT EXISTS wit_interface (
id INTEGER PRIMARY KEY,
-- The WIT text representation (full WIT document)
wit_text TEXT NOT NULL,
-- Parsed world name if available
world_name TEXT,
-- Number of ... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/migrations/07_package_name.sql | SQL | -- Add package_name column to wit_interface table
ALTER TABLE wit_interface ADD COLUMN package_name TEXT;
-- Create index for package_name lookups
CREATE INDEX IF NOT EXISTS idx_wit_interface_package_name ON wit_interface(package_name);
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/mod.rs | Rust | mod config;
mod models;
mod store;
mod wit_parser;
pub use config::StateInfo;
pub use models::ImageEntry;
pub use models::InsertResult;
pub use models::KnownPackage;
pub use models::WitInterface;
pub(crate) use store::Store;
| yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/models/image_entry.rs | Rust | use oci_client::manifest::OciImageManifest;
#[cfg(any(test, feature = "test-helpers"))]
use oci_client::manifest::{IMAGE_MANIFEST_MEDIA_TYPE, OciDescriptor};
use rusqlite::Connection;
/// Result of an insert operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InsertResult {
/// The entry was inserted ... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/models/known_package.rs | Rust | use rusqlite::Connection;
/// The type of a tag, used to distinguish release tags from signatures and attestations.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum TagType {
/// A regular release tag (e.g., "1.0.0", "latest")
Release,
/// A signature tag (ending in ".sig")
Signature,
/... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh | |
crates/package-manager/src/storage/models/migration.rs | Rust | use anyhow::Context;
use rusqlite::Connection;
/// A migration that can be applied to the database.
struct MigrationDef {
version: u32,
name: &'static str,
sql: &'static str,
}
/// All migrations in order. Each migration is run exactly once.
const MIGRATIONS: &[MigrationDef] = &[
MigrationDef {
... | yoshuawuyts/wasm | 0 | Unified developer tools for WebAssembly | Rust | yoshuawuyts | Yosh |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.