pub enum Mode {
Structure,
Signatures,
Types,
Full,
Minimal,
Pseudo,
}Expand description
Output transformation mode
ARCHITECTURE: Modes define what to keep/remove from source code. Each mode has different token reduction characteristics.
Variants§
Structure
Keep structure only - strip all implementation bodies
Token reduction: ~70-80%
Keeps:
- Function/method signatures
- Class declarations
- Type definitions
- Imports/exports
Removes:
- Function bodies (replaced with
{...}) - Implementation details
Signatures
Keep only function/method signatures
Token reduction: ~85-92%
More aggressive than Structure mode. Keeps ONLY callable signatures, removes everything else.
Types
Keep only type definitions
Token reduction: ~90-95%
Keeps:
- Type aliases
- Interface declarations
- Enum definitions
Removes:
- All implementation code
- Function bodies
- Class implementations
Full
No transformation - return original source
Token reduction: 0%
Useful for testing and comparing with other modes.
Minimal
Minimal cleanup - strip non-doc comments, normalize blank lines
Token reduction: ~15-30%
Keeps:
- All code (function bodies, implementations, variables, imports)
- Doc comments (JSDoc
/** */, Python docstrings, Rust//////!, Go doc, Javadoc) - Comments inside function bodies
- Shebangs (
#!/usr/bin/env python3)
Removes:
- Regular single-line comments (
//,#) at module/class level - Regular block comments (
/* */) at module/class level - Trailing whitespace left by comment removal
- Excessive blank lines (3+ consecutive -> 2)
Passthrough (return source unchanged):
- JSON, YAML, Markdown
Pseudo
Pseudo mode - strips syntactic noise while preserving logic flow
Token reduction: ~30-50%
Produces pseudocode-like output by removing type annotations, visibility modifiers, decorators, semicolons, and other syntactic noise while keeping all logic flow (function bodies, control flow, expressions).
Keeps:
- All logic (function bodies, control flow, expressions)
- Function/method/class names
- String literals and values
Removes:
- Type annotations and type parameters
- Visibility modifiers (pub, public, private, etc.)
- Decorators and attributes
- Statement-terminating semicolons
- Language-specific noise (lifetimes, where clauses, etc.)
Passthrough (return source unchanged):
- JSON, YAML, TOML, Markdown
Implementations§
Source§impl Mode
impl Mode
Sourcepub fn aggressiveness(self) -> u8
pub fn aggressiveness(self) -> u8
Returns the aggressiveness ordering for cascade purposes
Higher values mean more aggressive token reduction:
- Full(0): No transformation, 0% reduction
- Minimal(1): Strip non-doc comments, ~15-30% reduction
- Pseudo(2): Strip syntactic noise, ~30-50% reduction
- Structure(3): Strip bodies, ~70-80% reduction
- Signatures(4): Signatures only, ~85-92% reduction
- Types(5): Types only, ~90-95% reduction
Sourcepub fn cascade_from_here(self) -> &'static [Self]
pub fn cascade_from_here(self) -> &'static [Self]
Returns this mode and all more aggressive modes in cascade order
Used by the token budget cascade: try each mode from least to most aggressive until the output fits within the token budget.
Returns a static slice to avoid heap allocation on every call.
§Examples
use rskim_core::Mode;
let cascade = Mode::Structure.cascade_from_here();
assert_eq!(cascade, &[Mode::Structure, Mode::Signatures, Mode::Types]);
let cascade = Mode::Full.cascade_from_here();
assert_eq!(cascade, &[Mode::Full, Mode::Minimal, Mode::Pseudo, Mode::Structure, Mode::Signatures, Mode::Types]);Trait Implementations§
impl Copy for Mode
impl Eq for Mode
impl StructuralPartialEq for Mode
Auto Trait Implementations§
impl Freeze for Mode
impl RefUnwindSafe for Mode
impl Send for Mode
impl Sync for Mode
impl Unpin for Mode
impl UnsafeUnpin for Mode
impl UnwindSafe for Mode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.