Runs a command inside a memory-capped systemd-run --user scope, so a runaway process (cargo-mutants, trunk, rclone, ...) gets OOM-killed inside its own cgroup instead of the kernel OOM killer cascading into session.slice and killing ssh/gnome-keyring (the 'account got logged out' failure).
| Tier | tools |
| Role | unclassified (baselined) |
| Path | crates/tools/mem-guard |
| Edition | 2021 |
| Targets | tools-mem-guard, tools_mem_guard |
| Public items | 2 across 0 modules |
| Tests | 5 |
What it is for
Pure argument-building and validation for tools-mem-guard. No process spawning here so the decidable logic is unit-testable without systemd-run present (Gate 2.1 / PROCESS SS5).
Capabilities
crate root
Pure argument-building and validation for tools-mem-guard. No process spawning
| Item |
|---|
fn validate_mem_limit(s : & str) -> Result <(), String> |
fn build_scope_argv(max_mem : & str, max_swap : & str, cmd : & String,) -> Result <Vec <String>, String> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
fn validate_mem_limit(s : & str) -> Result <(), String> | systemd unit MemoryMax=/MemorySwapMax= accept a byte count with an optional K/M/G/T suffix, or the literal infinity |
fn build_scope_argv(max_mem : & str, max_swap : & str, cmd : & String,) -> Result <Vec <String>, String> | Builds the argv for systemd-run that runs cmd in a transient --user --scope unit capped at max_mem/max_swap |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier tools with 84 other crates: tools-advisory-reach, tools-archive-guard, tools-artifact-scaffold, tools-ask-ai-core, tools-ask-ais, tools-ask-gemini, tools-book, tools-book-report, … (84 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | tools |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/tools/mem-guard |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
anyhow | ^1 | — | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| bin | tools-mem-guard | `src/main.rs` |
| lib | tools_mem_guard | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 5 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 2 | 0 | 0 |
What the tests establish, by name:
accepts_plain_digits—src/lib.rsbuilds_expected_argv—src/lib.rsrejects_bad_limit_before_touching_command—src/lib.rsrejects_empty_command—src/lib.rsrejects_garbage—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 2 | 2 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 2
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 188 |
| Code lines | 154 |
| Public API items | 2 |
| Public modules | 0 |
| Tests | 5 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 1 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"function" : 2
pie showData
title Rust source composition
"Code" : 154
"Blank or comment" : 34
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.