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 |
|---|---|---|---|---|---|---|---|---|
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/swayfmt/src/module/mod.rs | swayfmt/src/module/mod.rs | use crate::{
comments::write_comments,
formatter::*,
utils::map::byte_span::{self, ByteSpan, LeafSpans},
};
use std::fmt::Write;
use sway_ast::{
keywords::{
ContractToken, Keyword, LibraryToken, PredicateToken, ScriptToken, SemicolonToken, Token,
},
Item, ItemKind, Module, ModuleKind,
};... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/swayfmt/src/module/item.rs | swayfmt/src/module/item.rs | use crate::{
formatter::*,
utils::map::byte_span::{ByteSpan, LeafSpans},
};
use sway_ast::ItemKind::{self, *};
impl Format for ItemKind {
fn format(
&self,
formatted_code: &mut FormattedCode,
formatter: &mut Formatter,
) -> Result<(), FormatterError> {
match self {
... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/swayfmt/tests/mod.rs | swayfmt/tests/mod.rs | use indoc::indoc;
use swayfmt::{config::user_def::FieldAlignment, Formatter};
use test_macros::assert_eq_pretty;
/// Takes a configured formatter as input and formats a given input and checks the actual output against an
/// expected output. There are two format passes to ensure that the received output does not chang... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/variable.rs | sway-ir/src/variable.rs | //! A value representing a function-local variable.
use crate::{
context::Context,
irtype::{Type, TypeContent},
pretty::DebugWithContext,
Constant,
};
/// A wrapper around an [ECS](https://github.com/orlp/slotmap) handle into the
/// [`Context`].
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Debug... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/lib.rs | sway-ir/src/lib.rs | //! Sway-IR is a library providing an intermediate representation for the
//! [Sway](https://github.com/FuelLabs/sway) compiler pipeline.
//!
//! It is inspired heavily by [LLVM](https://llvm.org/docs/LangRef.html) although it aims to remain
//! a much simpler system, providing only that which is required by Sway to ta... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/asm.rs | sway-ir/src/asm.rs | //! An 'asm' block represents an opaque set of Fuel VM assembly instructions, embedded in place and
//! intended to be inserted as is into the assembly code generation.
//!
//! An [`AsmBlock`] has symbols for arguments and an optional return name and contains a list of
//! [`AsmInstruction`].
//!
//! The syntax in Sway... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/instruction.rs | sway-ir/src/instruction.rs | //! Instructions for data manipulation, but mostly control flow.
//!
//! Since Sway abstracts most low level operations behind traits they are translated into function
//! calls which contain ASM blocks.
//!
//! Unfortunately, using opaque ASM blocks limits the effectiveness of certain optimizations and
//! this should... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/parser.rs | sway-ir/src/parser.rs | //! A parser for the printed IR, useful mostly for testing.
use sway_features::ExperimentalFeatures;
use sway_types::SourceEngine;
use crate::{context::Context, error::IrError, Backtrace};
// -------------------------------------------------------------------------------------------------
/// Parse a string produced... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/pass_manager.rs | sway-ir/src/pass_manager.rs | use crate::{
create_arg_demotion_pass, create_arg_pointee_mutability_tagger_pass, create_ccp_pass,
create_const_demotion_pass, create_const_folding_pass, create_cse_pass, create_dce_pass,
create_dom_fronts_pass, create_dominators_pass, create_escaped_symbols_pass,
create_fn_dedup_debug_profile_pass, cre... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/module.rs | sway-ir/src/module.rs | //! A scope containing a collection of [`Function`]s and constant values.
//!
//! A module also has a 'kind' corresponding to the different Sway module types.
use std::{cell::Cell, collections::BTreeMap};
use crate::{
context::Context,
function::{Function, FunctionIterator},
Constant, GlobalVar, MetadataI... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/analysis.rs | sway-ir/src/analysis.rs | pub mod call_graph;
pub use call_graph::*;
pub mod dominator;
pub use dominator::*;
pub mod memory_utils;
pub use memory_utils::*;
| rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize.rs | sway-ir/src/optimize.rs | //! A collection of optimization passes.
//!
//! Each of these modules are a collection of typical code optimisation passes.
//!
//! Currently there is no pass manager, as there are only a couple of passes, but this is something
//! which will be added in the future.
//!
//! So each of the functions under this module w... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/value.rs | sway-ir/src/value.rs | //! The base descriptor for various values within the IR.
//!
//! [`Value`]s can be function arguments, constants and instructions. [`Instruction`]s generally
//! refer to each other and to constants via the [`Value`] wrapper.
//!
//! Like most IR data structures they are `Copy` and cheap to pass around by value. They ... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/function.rs | sway-ir/src/function.rs | //! A typical function data type.
//!
//! [`Function`] is named, takes zero or more arguments and has an optional return value. It
//! contains a collection of [`Block`]s.
//!
//! It also maintains a collection of local values which can be typically regarded as variables
//! existing in the function scope.
use std::c... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/block.rs | sway-ir/src/block.rs | //! Represents a 'basic block' of [`Instruction`]s in a control flow graph.
//!
//! [`Block`]s contain zero or more _non-terminating_ instructions and at most one _terminating_
//! instruction or _terminator_. Terminators are either branches or a return instruction and are
//! the last instruction in the block.
//!
//... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/error.rs | sway-ir/src/error.rs | /// These errors are for internal IR failures, not designed to be useful to a Sway developer, but
/// more for users of the `sway-ir` crate, i.e., compiler developers.
///
/// XXX They're not very rich and could do with a little more verbosity.
#[derive(Debug)]
pub enum IrError {
FunctionLocalClobbered(String, Str... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/printer.rs | sway-ir/src/printer.rs | //! Print (or serialize) IR to human and machine readable text.
//!
//! This module implements a document based pretty-printer. A couple of 3rd party pretty printing
//! crates were assessed but didn't seem to work as well as this simple version, which is quite
//! effective.
use std::collections::{BTreeMap, HashMap}... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/irtype.rs | sway-ir/src/irtype.rs | //! Each of the valid `Value` types.
//!
//! These generally mimic the Sway types with a couple of exceptions:
//! - [`Type::Unit`] is still a discrete type rather than an empty tuple. This may change in the
//! future.
//! - [`Type::Union`] is a sum type which resembles a C union. Each member of the union uses the... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/verify.rs | sway-ir/src/verify.rs | //! Code to validate the IR in a [`Context`].
//!
//! During creation, deserialization and optimization the IR should be verified to be in a
//! consistent valid state, using the functions in this module.
use itertools::Itertools;
use crate::{
context::Context,
error::IrError,
function::Function,
inst... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/constant.rs | sway-ir/src/constant.rs | //! [`Constant`] is a typed constant value.
use std::hash::{Hash, Hasher};
use crate::{context::Context, irtype::Type, pretty::DebugWithContext, value::Value, Padding};
use rustc_hash::FxHasher;
use sway_types::u256::U256;
/// A wrapper around an [ECS](https://github.com/orlp/slotmap) handle into the
/// [`Context`]... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/context.rs | sway-ir/src/context.rs | //! The main handle to an IR instance.
//!
//! [`Context`] contains several
//! [slotmap](https://github.com/orlp/slotmap) collections to maintain the
//! IR ECS.
//!
//! It is passed around as a mutable reference to many of the Sway-IR APIs.
use rustc_hash::FxHashMap;
use slotmap::{DefaultKey, SlotMap};
use sway_feat... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/metadata.rs | sway-ir/src/metadata.rs | use sway_types::SourceId;
/// Associated metadata attached mostly to values.
///
/// Each value (instruction, function argument or constant) has associated metadata which helps
/// describe properties which aren't required for code generation, but help with other
/// introspective tools (e.g., the debugger) or compile... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/pretty.rs | sway-ir/src/pretty.rs | pub use sway_ir_macros::*;
use {crate::Context, std::fmt};
pub struct WithContext<'a, 'c, 'eng, T: ?Sized> {
thing: &'a T,
context: &'c Context<'eng>,
}
pub trait DebugWithContext {
fn fmt_with_context(&self, formatter: &mut fmt::Formatter, context: &Context) -> fmt::Result;
fn with_context<'a, 'c, '... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/storage_key.rs | sway-ir/src/storage_key.rs | //! A value representing a storage key. Every storage field access in the program
//! corresponds to a [StorageKey].
use std::vec;
use crate::{
context::Context, irtype::Type, pretty::DebugWithContext, Constant, ConstantContent,
ConstantValue, B256,
};
/// A wrapper around an [ECS](https://github.com/orlp/sl... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/cse.rs | sway-ir/src/optimize/cse.rs | //! Value numbering based common subexpression elimination.
//! Reference: Value Driven Redundancy Elimination - Loren Taylor Simpson.
use core::panic;
use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
use slotmap::Key;
use std::{
collections::hash_map,
fmt::Debug,
hash::{Hash, Ha... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/ret_demotion.rs | sway-ir/src/optimize/ret_demotion.rs | /// Return value demotion.
///
/// This pass demotes 'by-value' function return types to 'by-reference` pointer types, based on
/// target specific parameters.
///
/// An extra argument pointer is added to the function.
/// The return value is mem_copied to the new argument instead of being returned by value.
use crate... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/target_fuel.rs | sway-ir/src/optimize/target_fuel.rs | //! Some Fuel VM specific utilities.
use crate::{
context::Context,
irtype::{Type, TypeContent},
};
/// Return whether a [Type] _cannot_ fit in a Fuel VM register and requires 'demotion'.
pub(super) fn is_demotable_type(context: &Context, ty: &Type) -> bool {
match ty.get_content(context) {
TypeCon... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/fn_dedup.rs | sway-ir/src/optimize/fn_dedup.rs | //! ## Deduplicate functions.
//!
//! If two functions are functionally identical, eliminate one
//! and replace all calls to it with a call to the retained one.
//!
//! This pass shouldn't be required once the monomorphiser stops
//! generating a new function for each instantiation even when the exact
//! same instant... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/const_demotion.rs | sway-ir/src/optimize/const_demotion.rs | /// Constant value demotion.
///
/// This pass demotes 'by-value' constant types to 'by-reference` pointer types, based on target
/// specific parameters.
///
/// Storage for constant values is created on the stack in variables which are initialized with the
/// original values.
use crate::{
AnalysisResults, Block,... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/arg_demotion.rs | sway-ir/src/optimize/arg_demotion.rs | /// Function argument demotion.
///
/// This pass demotes 'by-value' function arg types to 'by-reference` pointer types, based on target
/// specific parameters.
use crate::{
AnalysisResults, Block, BlockArgument, Context, Function, InstOp, Instruction,
InstructionInserter, IrError, Module, Pass, PassMutability... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/misc_demotion.rs | sway-ir/src/optimize/misc_demotion.rs | use std::ops::Not;
/// Miscellaneous value demotion.
///
/// This pass demotes miscellaneous 'by-value' types to 'by-reference' pointer types, based on
/// target specific parameters.
///
/// Current special cases are:
/// - log arguments: These can be any type and should be demoted to pointers if possible.
/// - Fuel... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/inline.rs | sway-ir/src/optimize/inline.rs | //! Function inlining.
//!
//! Function inlining is pretty hairy so these passes must be maintained with care.
use std::{cell::RefCell, collections::HashMap};
use rustc_hash::FxHashMap;
use crate::{
asm::AsmArg,
block::Block,
call_graph, compute_post_order,
context::Context,
error::IrError,
f... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/memcpyopt.rs | sway-ir/src/optimize/memcpyopt.rs | //! Optimisations related to mem_copy.
//! - replace a `store` directly from a `load` with a `mem_copy_val`.
use indexmap::IndexMap;
use itertools::{Either, Itertools};
use rustc_hash::{FxHashMap, FxHashSet};
use sway_types::{FxIndexMap, FxIndexSet};
use crate::{
get_gep_symbol, get_loaded_symbols, get_referred_s... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | true |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/mem2reg.rs | sway-ir/src/optimize/mem2reg.rs | use indexmap::IndexMap;
/// Promote local memory to SSA registers.
/// This pass is essentially SSA construction. A good readable reference is:
/// https://www.cs.princeton.edu/~appel/modern/c/
/// We use block arguments instead of explicit PHI nodes. Conceptually,
/// they are both the same.
use rustc_hash::FxHashMap;... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/sroa.rs | sway-ir/src/optimize/sroa.rs | //! Scalar Replacement of Aggregates
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{
combine_indices, get_gep_referred_symbols, get_loaded_ptr_values, get_stored_ptr_values,
pointee_size, AnalysisResults, Constant, ConstantValue, Context, EscapedSymbols, Function,
InstOp, IrError, LocalVar, Pass, Pas... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/conditional_constprop.rs | sway-ir/src/optimize/conditional_constprop.rs | //! When a value is guaranteed to have a constant value in a region of the CFG,
//! this optimization replaces uses of that value with the constant in that region.
use rustc_hash::FxHashMap;
use crate::{
AnalysisResults, Context, DomTree, Function, InstOp, Instruction, IrError, Pass,
PassMutability, Predicate... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/arg_mutability_tagger.rs | sway-ir/src/optimize/arg_mutability_tagger.rs | //! Tags function pointer arguments as immutable based on their usage.
use crate::{
build_call_graph, callee_first_order, AnalysisResults, BinaryOpKind, Context,
FuelVmInstruction, Function, InstOp, IrError, Module, Pass, PassMutability, ScopedPass, Value,
ValueDatum,
};
use rustc_hash::{FxHashMap, FxHashS... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/constants.rs | sway-ir/src/optimize/constants.rs | //! Optimization passes for manipulating constant values.
use crate::{
constant::{ConstantContent, ConstantValue},
context::Context,
error::IrError,
function::Function,
instruction::InstOp,
value::ValueDatum,
AnalysisResults, BranchToWithArgs, Constant, Instruction, Pass, PassMutability, Pr... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/dce.rs | sway-ir/src/optimize/dce.rs | //! ## Dead Code Elimination
//!
//! This optimization removes unused definitions. The pass is a combination of:
//! 1. A liveness analysis that keeps track of the uses of a definition,
//! 2. At the time of inspecting a definition, if it has no uses, it is removed.
//!
//! This pass does not do CFG transformations... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/optimize/simplify_cfg.rs | sway-ir/src/optimize/simplify_cfg.rs | //! ## Simplify Control Flow Graph
//!
//! The optimizations here aim to reduce the complexity in control flow by removing basic blocks.
//! This may be done by removing 'dead' blocks which are no longer called (or in other words, have
//! no predecessors) or by merging blocks which are linked by a single unconditional... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/analysis/dominator.rs | sway-ir/src/analysis/dominator.rs | use crate::{
block::Block, AnalysisResult, AnalysisResultT, AnalysisResults, BranchToWithArgs, Context,
Function, IrError, Pass, PassMutability, ScopedPass, Value,
};
use indexmap::IndexSet;
/// Dominator tree and related algorithms.
/// The algorithms implemented here are from the paper
// "A Simple, Fast Domi... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/analysis/call_graph.rs | sway-ir/src/analysis/call_graph.rs | /// Build call graphs for the program being compiled.
/// If a function F1 calls function F2, then the call
/// graph has an edge F1->F2.
use crate::{Context, Function, InstOp, Instruction, ValueDatum};
use indexmap::IndexSet;
use sway_types::{FxIndexMap, FxIndexSet};
pub type CallGraph = FxIndexMap<Function, FxIndex... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/analysis/memory_utils.rs | sway-ir/src/analysis/memory_utils.rs | //! An analysis to compute symbols that escape out from a function.
//! This could be into another function, or via `ptr_to_int` etc.
//! Any transformations involving such symbols are unsafe.
use indexmap::IndexSet;
use rustc_hash::FxHashSet;
use sway_types::{FxIndexMap, FxIndexSet};
use crate::{
AnalysisResult,... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/src/bin/opt.rs | sway-ir/src/bin/opt.rs | use std::{
io::{BufReader, BufWriter, Read, Write},
process::exit,
};
use anyhow::anyhow;
use sway_features::ExperimentalFeatures;
use sway_ir::{
insert_after_each, register_known_passes, Backtrace, PassGroup, PassManager,
MODULE_PRINTER_NAME, MODULE_VERIFIER_NAME,
};
use sway_types::SourceEngine;
// ... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/tests/tests.rs | sway-ir/tests/tests.rs | use std::path::PathBuf;
use itertools::Itertools;
use sway_features::ExperimentalFeatures;
use sway_ir::{
create_arg_demotion_pass, create_arg_pointee_mutability_tagger_pass, create_ccp_pass,
create_const_demotion_pass, create_const_folding_pass, create_cse_pass, create_dce_pass,
create_dom_fronts_pass, cr... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-ir/sway-ir-macros/src/lib.rs | sway-ir/sway-ir-macros/src/lib.rs | use {
itertools::Itertools,
proc_macro::TokenStream,
quote::{format_ident, quote},
syn::{
parse_macro_input, Attribute, Data, DeriveInput, Fields, FieldsNamed, FieldsUnnamed, Ident,
Variant,
},
};
#[proc_macro_derive(DebugWithContext, attributes(in_context))]
pub fn derive_debug_wit... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-utils/src/lib.rs | sway-utils/src/lib.rs | pub mod constants;
pub mod helpers;
pub mod mapped_stack;
pub mod performance;
pub use constants::*;
pub use helpers::*;
pub use mapped_stack::*;
pub use performance::*;
| rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-utils/src/mapped_stack.rs | sway-utils/src/mapped_stack.rs | use std::collections::HashMap;
/// A HashMap that can hold multiple values and
/// fetch values in a LIFO manner. Rust's MultiMap
/// handles values in a FIFO manner.
#[derive(Debug)]
pub struct MappedStack<K: std::cmp::Eq + std::hash::Hash, V> {
container: HashMap<K, Vec<V>>,
}
impl<K: std::cmp::Eq + std::hash::... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-utils/src/helpers.rs | sway-utils/src/helpers.rs | use crate::constants;
use std::{
ffi::OsStr,
fs,
path::{Path, PathBuf},
};
use walkdir::WalkDir;
pub fn get_sway_files(path: PathBuf) -> Vec<PathBuf> {
let mut files = vec![];
let mut dir_entries = vec![path];
while let Some(next_dir) = dir_entries.pop() {
if let Ok(read_dir) = fs::rea... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-utils/src/constants.rs | sway-utils/src/constants.rs | pub const MANIFEST_FILE_NAME: &str = "Forc.toml";
pub const LOCK_FILE_NAME: &str = "Forc.lock";
pub const TEST_MANIFEST_FILE_NAME: &str = "Cargo.toml";
pub const TEST_DIRECTORY: &str = "tests";
pub const SWAY_EXTENSION: &str = "sw";
pub const USER_FORC_DIRECTORY: &str = ".forc";
pub const SRC_DIR: &str = "src";
pub con... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-utils/src/performance.rs | sway-utils/src/performance.rs | use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PerformanceMetric {
pub phase: String,
pub elapsed: f64,
pub memory_usage: Option<u64>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct PerformanceData {
pub bytecode_size: usize,
... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
FuelLabs/sway | https://github.com/FuelLabs/sway/blob/cc8f867043f3ec2c14ec4088d449cde603929a80/sway-features/src/lib.rs | sway-features/src/lib.rs | use std::collections::HashMap;
use clap::{Parser, ValueEnum};
macro_rules! features {
($($name:ident = $enabled:literal, $url:literal),* $(,)?) => {
paste::paste! {
#[derive(Copy, Clone, Debug, ValueEnum, PartialEq, Eq, Hash)]
#[value(rename_all = "snake")]
pub enum Fea... | rust | Apache-2.0 | cc8f867043f3ec2c14ec4088d449cde603929a80 | 2026-01-04T15:31:58.694488Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/build.rs | crates/atuin-daemon/build.rs | use std::{env, fs, path::PathBuf};
use protox::prost::Message;
fn main() -> std::io::Result<()> {
let proto_paths = ["proto/history.proto"];
let proto_include_dirs = ["proto"];
let file_descriptors = protox::compile(proto_paths, proto_include_dirs).unwrap();
let file_descriptor_path = PathBuf::from(... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/src/lib.rs | crates/atuin-daemon/src/lib.rs | pub mod client;
pub mod history;
pub mod server;
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/src/client.rs | crates/atuin-daemon/src/client.rs | use eyre::{Context, Result};
#[cfg(windows)]
use tokio::net::TcpStream;
use tonic::transport::{Channel, Endpoint, Uri};
use tower::service_fn;
use hyper_util::rt::TokioIo;
#[cfg(unix)]
use tokio::net::UnixStream;
use atuin_client::history::History;
use crate::history::{
EndHistoryRequest, StartHistoryRequest, h... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/src/history.rs | crates/atuin-daemon/src/history.rs | tonic::include_proto!("history");
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/src/server.rs | crates/atuin-daemon/src/server.rs | use eyre::WrapErr;
use atuin_client::encryption;
use atuin_client::history::store::HistoryStore;
use atuin_client::record::sqlite_store::SqliteStore;
use atuin_client::settings::Settings;
#[cfg(unix)]
use std::path::PathBuf;
use std::sync::Arc;
use time::OffsetDateTime;
use tracing::{Level, instrument};
use atuin_cli... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-daemon/src/server/sync.rs | crates/atuin-daemon/src/server/sync.rs | use eyre::Result;
use rand::Rng;
use tokio::time::{self, MissedTickBehavior};
use atuin_client::database::Sqlite as HistoryDatabase;
use atuin_client::{
encryption,
history::store::HistoryStore,
record::{sqlite_store::SqliteStore, sync},
settings::Settings,
};
use atuin_dotfiles::store::{AliasStore, v... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server-sqlite/build.rs | crates/atuin-server-sqlite/build.rs | // generated by `sqlx migrate build-script`
fn main() {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
}
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server-sqlite/src/wrappers.rs | crates/atuin-server-sqlite/src/wrappers.rs | use ::sqlx::{FromRow, Result};
use atuin_common::record::{EncryptedData, Host, Record};
use atuin_server_database::models::{History, Session, User};
use sqlx::{Row, sqlite::SqliteRow};
pub struct DbUser(pub User);
pub struct DbSession(pub Session);
pub struct DbHistory(pub History);
pub struct DbRecord(pub Record<Encr... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server-sqlite/src/lib.rs | crates/atuin-server-sqlite/src/lib.rs | use std::str::FromStr;
use async_trait::async_trait;
use atuin_common::{
record::{EncryptedData, HostId, Record, RecordIdx, RecordStatus},
utils::crypto_random_string,
};
use atuin_server_database::{
Database, DbError, DbResult, DbSettings,
models::{History, NewHistory, NewSession, NewUser, Session, Us... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-history/src/stats.rs | crates/atuin-history/src/stats.rs | use std::collections::{HashMap, HashSet};
use crossterm::style::{Color, ResetColor, SetAttribute, SetForegroundColor};
use serde::{Deserialize, Serialize};
use unicode_segmentation::UnicodeSegmentation;
use atuin_client::{history::History, settings::Settings, theme::Meaning, theme::Theme};
#[derive(Debug, Clone, Ser... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-history/src/lib.rs | crates/atuin-history/src/lib.rs | pub mod sort;
pub mod stats;
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-history/src/sort.rs | crates/atuin-history/src/sort.rs | use atuin_client::history::History;
type ScoredHistory = (f64, History);
// Fuzzy search already comes sorted by minspan
// This sorting should be applicable to all search modes, and solve the more "obvious" issues
// first.
// Later on, we can pass in context and do some boosts there too.
pub fn sort(query: &str, in... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-history/benches/smart_sort.rs | crates/atuin-history/benches/smart_sort.rs | use atuin_client::history::History;
use atuin_history::sort::sort;
use rand::Rng;
fn main() {
// Run registered benchmarks.
divan::main();
}
// Smart sort usually runs on 200 entries, test on a few sizes
#[divan::bench(args=[100, 200, 400, 800, 1600, 10000])]
fn smart_sort(lines: usize) {
// benchmark a ... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/settings.rs | crates/atuin-scripts/src/settings.rs | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false | |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/lib.rs | crates/atuin-scripts/src/lib.rs | pub mod database;
pub mod execution;
pub mod settings;
pub mod store;
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/store.rs | crates/atuin-scripts/src/store.rs | use eyre::{Result, bail};
use atuin_client::record::sqlite_store::SqliteStore;
use atuin_client::record::{encryption::PASETO_V4, store::Store};
use atuin_common::record::{Host, HostId, Record, RecordId, RecordIdx};
use record::ScriptRecord;
use script::{SCRIPT_TAG, SCRIPT_VERSION, Script};
use crate::database::Databa... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/database.rs | crates/atuin-scripts/src/database.rs | use std::{path::Path, str::FromStr, time::Duration};
use atuin_common::utils;
use sqlx::{
Result, Row,
sqlite::{
SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow,
SqliteSynchronous,
},
};
use tokio::fs;
use tracing::debug;
use uuid::Uuid;
use crate::store::... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/execution.rs | crates/atuin-scripts/src/execution.rs | use crate::store::script::Script;
use eyre::Result;
use std::collections::{HashMap, HashSet};
use std::process::Stdio;
use tempfile::NamedTempFile;
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::sync::mpsc;
use tokio::task;
use tracing::debug;
// Helper function to build a complete script with she... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/store/record.rs | crates/atuin-scripts/src/store/record.rs | use atuin_common::record::DecryptedData;
use eyre::{Result, eyre};
use uuid::Uuid;
use crate::store::script::SCRIPT_VERSION;
use super::script::Script;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ScriptRecord {
Create(Script),
Update(Script),
Delete(Uuid),
}
impl ScriptRecord {
pub fn serialize(... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-scripts/src/store/script.rs | crates/atuin-scripts/src/store/script.rs | use atuin_common::record::DecryptedData;
use eyre::{Result, bail, ensure};
use uuid::Uuid;
use rmp::{
decode::{self, Bytes},
encode,
};
use typed_builder::TypedBuilder;
pub const SCRIPT_VERSION: &str = "v0";
pub const SCRIPT_TAG: &str = "script";
pub const SCRIPT_LEN: usize = 20000; // 20kb max total len
#[d... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/settings.rs | crates/atuin-server/src/settings.rs | use std::{io::prelude::*, path::PathBuf};
use atuin_server_database::DbSettings;
use config::{Config, Environment, File as ConfigFile, FileFormat};
use eyre::{Result, eyre};
use fs_err::{File, create_dir_all};
use serde::{Deserialize, Serialize};
static EXAMPLE_CONFIG: &str = include_str!("../server.toml");
#[derive... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/router.rs | crates/atuin-server/src/router.rs | use async_trait::async_trait;
use atuin_common::api::{ATUIN_CARGO_VERSION, ATUIN_HEADER_VERSION, ErrorResponse};
use axum::{
Router,
extract::{FromRequestParts, Request},
http::{self, request::Parts},
middleware::Next,
response::{IntoResponse, Response},
routing::{delete, get, patch, post},
};
u... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/lib.rs | crates/atuin-server/src/lib.rs | #![forbid(unsafe_code)]
use std::future::Future;
use std::net::SocketAddr;
use atuin_server_database::Database;
use axum::{Router, serve};
use axum_server::Handle;
use axum_server::tls_rustls::RustlsConfig;
use eyre::{Context, Result, eyre};
mod handlers;
mod metrics;
mod router;
mod utils;
pub use settings::Settin... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/utils.rs | crates/atuin-server/src/utils.rs | use eyre::Result;
use semver::{Version, VersionReq};
pub fn client_version_min(user_agent: &str, req: &str) -> Result<bool> {
if user_agent.is_empty() {
return Ok(false);
}
let version = user_agent.replace("atuin/", "");
let req = VersionReq::parse(req)?;
let version = Version::parse(vers... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/metrics.rs | crates/atuin-server/src/metrics.rs | use std::time::Instant;
use axum::{
extract::{MatchedPath, Request},
middleware::Next,
response::IntoResponse,
};
use metrics_exporter_prometheus::{Matcher, PrometheusBuilder, PrometheusHandle};
pub fn setup_metrics_recorder() -> PrometheusHandle {
const EXPONENTIAL_SECONDS: &[f64] = &[
0.005,... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/user.rs | crates/atuin-server/src/handlers/user.rs | use std::borrow::Borrow;
use std::collections::HashMap;
use std::time::Duration;
use argon2::{
Algorithm, Argon2, Params, PasswordHash, PasswordHasher, PasswordVerifier, Version,
password_hash::SaltString,
};
use axum::{
Json,
extract::{Path, State},
http::StatusCode,
};
use metrics::counter;
use ... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/status.rs | crates/atuin-server/src/handlers/status.rs | use axum::{Json, extract::State, http::StatusCode};
use tracing::instrument;
use super::{ErrorResponse, ErrorResponseStatus, RespExt};
use crate::router::{AppState, UserAuth};
use atuin_server_database::Database;
use atuin_common::api::*;
const VERSION: &str = env!("CARGO_PKG_VERSION");
#[instrument(skip_all, field... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/history.rs | crates/atuin-server/src/handlers/history.rs | use std::{collections::HashMap, convert::TryFrom};
use axum::{
Json,
extract::{Path, Query, State},
http::{HeaderMap, StatusCode},
};
use metrics::counter;
use time::{Month, UtcOffset};
use tracing::{debug, error, instrument};
use super::{ErrorResponse, ErrorResponseStatus, RespExt};
use crate::{
rout... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/record.rs | crates/atuin-server/src/handlers/record.rs | use axum::{Json, http::StatusCode, response::IntoResponse};
use serde_json::json;
use tracing::instrument;
use super::{ErrorResponse, ErrorResponseStatus, RespExt};
use crate::router::UserAuth;
use atuin_common::record::{EncryptedData, Record};
#[instrument(skip_all, fields(user.id = user.id))]
pub async fn post(Use... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/mod.rs | crates/atuin-server/src/handlers/mod.rs | use atuin_common::api::{ErrorResponse, IndexResponse};
use atuin_server_database::Database;
use axum::{Json, extract::State, http, response::IntoResponse};
use crate::router::AppState;
pub mod health;
pub mod history;
pub mod record;
pub mod status;
pub mod user;
pub mod v0;
const VERSION: &str = env!("CARGO_PKG_VER... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/health.rs | crates/atuin-server/src/handlers/health.rs | use axum::{Json, http, response::IntoResponse};
use serde::Serialize;
#[derive(Serialize)]
pub struct HealthResponse {
pub status: &'static str,
}
pub async fn health_check() -> impl IntoResponse {
(
http::StatusCode::OK,
Json(HealthResponse { status: "healthy" }),
)
}
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/v0/store.rs | crates/atuin-server/src/handlers/v0/store.rs | use axum::{extract::Query, extract::State, http::StatusCode};
use metrics::counter;
use serde::Deserialize;
use tracing::{error, instrument};
use crate::{
handlers::{ErrorResponse, ErrorResponseStatus, RespExt},
router::{AppState, UserAuth},
};
use atuin_server_database::Database;
#[derive(Deserialize)]
pub s... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/v0/me.rs | crates/atuin-server/src/handlers/v0/me.rs | use axum::Json;
use tracing::instrument;
use crate::handlers::ErrorResponseStatus;
use crate::router::UserAuth;
use atuin_common::api::*;
#[instrument(skip_all, fields(user.id = user.id))]
pub async fn get(
UserAuth(user): UserAuth,
) -> Result<Json<MeResponse>, ErrorResponseStatus<'static>> {
Ok(Json(MeResp... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/v0/record.rs | crates/atuin-server/src/handlers/v0/record.rs | use axum::{Json, extract::Query, extract::State, http::StatusCode};
use metrics::counter;
use serde::Deserialize;
use tracing::{error, instrument};
use crate::{
handlers::{ErrorResponse, ErrorResponseStatus, RespExt},
router::{AppState, UserAuth},
};
use atuin_server_database::Database;
use atuin_common::reco... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-server/src/handlers/v0/mod.rs | crates/atuin-server/src/handlers/v0/mod.rs | pub(crate) mod me;
pub(crate) mod record;
pub(crate) mod store;
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/lib.rs | crates/atuin-common/src/lib.rs | #![deny(unsafe_code)]
/// Defines a new UUID type wrapper
macro_rules! new_uuid {
($name:ident) => {
#[derive(
Debug,
Copy,
Clone,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
serde::Serialize,
... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/shell.rs | crates/atuin-common/src/shell.rs | use std::{ffi::OsStr, path::Path, process::Command};
use serde::Serialize;
use sysinfo::{Process, System, get_current_pid};
use thiserror::Error;
#[derive(PartialEq)]
pub enum Shell {
Sh,
Bash,
Fish,
Zsh,
Xonsh,
Nu,
Powershell,
Unknown,
}
impl std::fmt::Display for Shell {
fn fmt... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/calendar.rs | crates/atuin-common/src/calendar.rs | // Calendar data
use serde::{Serialize, Deserialize};
pub enum TimePeriod {
YEAR,
MONTH,
DAY,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TimePeriodInfo {
pub count: u64,
// TODO: Use this for merkle tree magic
pub hash: String,
}
| rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/api.rs | crates/atuin-common/src/api.rs | use lazy_static::lazy_static;
use semver::Version;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use time::OffsetDateTime;
// the usage of X- has been deprecated for quite along time, it turns out
pub static ATUIN_HEADER_VERSION: &str = "Atuin-Version";
pub static ATUIN_CARGO_VERSION: &str = env!("CARGO_P... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/utils.rs | crates/atuin-common/src/utils.rs | use std::borrow::Cow;
use std::env;
use std::path::PathBuf;
use eyre::{Result, eyre};
use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine};
use getrandom::getrandom;
use uuid::Uuid;
/// Generate N random bytes, using a cryptographically secure source
pub fn crypto_random_bytes<const N: usize>() -> [u8; N] {
// ... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-common/src/record.rs | crates/atuin-common/src/record.rs | use std::collections::HashMap;
use eyre::Result;
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
use uuid::Uuid;
#[derive(Clone, Debug, PartialEq)]
pub struct DecryptedData(pub Vec<u8>);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EncryptedData {
pub data: String,
... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/settings.rs | crates/atuin-client/src/settings.rs | use std::{
collections::HashMap, convert::TryFrom, fmt, io::prelude::*, path::PathBuf, str::FromStr,
};
use atuin_common::record::HostId;
use atuin_common::utils;
use clap::ValueEnum;
use config::{
Config, ConfigBuilder, Environment, File as ConfigFile, FileFormat, builder::DefaultState,
};
use eyre::{Context,... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | true |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/register.rs | crates/atuin-client/src/register.rs | use eyre::Result;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use crate::{api_client, settings::Settings};
pub async fn register(
settings: &Settings,
username: String,
email: String,
password: String,
) -> Result<String> {
let session =
api_client::register(settings.sync_address.as... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/lib.rs | crates/atuin-client/src/lib.rs | #![deny(unsafe_code)]
#[macro_use]
extern crate log;
#[cfg(feature = "sync")]
pub mod api_client;
#[cfg(feature = "sync")]
pub mod sync;
pub mod database;
pub mod encryption;
pub mod history;
pub mod import;
pub mod login;
pub mod logout;
pub mod ordering;
pub mod plugin;
pub mod record;
pub mod register;
pub mod se... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/theme.rs | crates/atuin-client/src/theme.rs | use config::{Config, File as ConfigFile, FileFormat};
use lazy_static::lazy_static;
use log;
use palette::named;
use serde::{Deserialize, Serialize};
use serde_json;
use std::collections::HashMap;
use std::error;
use std::io::{Error, ErrorKind};
use std::path::PathBuf;
use strum_macros;
static DEFAULT_MAX_DEPTH: u8 = ... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/ordering.rs | crates/atuin-client/src/ordering.rs | use minspan::minspan;
use super::{history::History, settings::SearchMode};
pub fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> Vec<History> {
match mode {
SearchMode::Fuzzy => reorder(query, |x| &x.command, res),
_ => res,
}
}
fn reorder<F, A>(query: &str, f: F, res: Vec... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/sync.rs | crates/atuin-client/src/sync.rs | use std::collections::HashSet;
use std::iter::FromIterator;
use eyre::Result;
use atuin_common::api::AddHistoryRequest;
use crypto_secretbox::Key;
use time::OffsetDateTime;
use crate::{
api_client,
database::Database,
encryption::{decrypt, encrypt, load_key},
settings::Settings,
};
pub fn hash_str(s... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
atuinsh/atuin | https://github.com/atuinsh/atuin/blob/8a010fed33ce19a9ddc589196c73c07ba7ba88e7/crates/atuin-client/src/login.rs | crates/atuin-client/src/login.rs | use std::path::PathBuf;
use atuin_common::api::LoginRequest;
use eyre::{Context, Result, bail};
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use crate::{
api_client,
encryption::{Key, decode_key, encode_key, load_key},
record::{sqlite_store::SqliteStore, store::Store},
settings::Settings,
};
pu... | rust | MIT | 8a010fed33ce19a9ddc589196c73c07ba7ba88e7 | 2026-01-04T15:36:14.139439Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.