Skip to main content

Mode

Enum Mode 

Source
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

Source

pub fn parse(s: &str) -> Option<Self>

Parse mode from string (for CLI/API)

Source

pub fn name(self) -> &'static str

Get mode name for display

Source

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
Source

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§

Source§

impl Clone for Mode

Source§

fn clone(&self) -> Mode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Mode

Source§

impl Debug for Mode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Mode

Source§

impl Hash for Mode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Mode

Source§

fn eq(&self, other: &Mode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.