NntpCommand

Enum NntpCommand 

Source
pub enum NntpCommand {
    AuthUser,
    AuthPass,
    Stateful,
    NonRoutable,
    Stateless,
    ArticleByMessageId,
}
Expand description

NNTP command classification for routing and handling strategy

This enum determines how commands are processed by the proxy based on their semantics and state requirements per RFC 3977.

§Classification Categories

  • ArticleByMessageId: High-throughput binary retrieval (can be multiplexed)

    • Commands: ARTICLE/BODY/HEAD/STAT with message-ID argument
    • Per RFC 3977 §6.2
    • 70%+ of NZB download traffic
  • Stateful: Requires session state (GROUP context, article numbers)

    • Commands: GROUP, ARTICLE/BODY/HEAD/STAT by number, NEXT, LAST, XOVER, etc.
    • Per RFC 3977 §6.1
    • Requires dedicated backend connection with maintained state
  • NonRoutable: Cannot be safely proxied (POST, IHAVE, etc.)

    • Commands: POST, IHAVE, NEWGROUPS, NEWNEWS
    • Per RFC 3977 §6.3
    • Typically rejected or require special handling
  • Stateless: Can be proxied without state

    • Commands: LIST, DATE, CAPABILITIES, HELP, QUIT, etc.
    • Per RFC 3977 §7
    • Safe to execute on any backend connection
  • AuthUser/AuthPass: Authentication (intercepted by proxy)

    • Commands: AUTHINFO USER, AUTHINFO PASS
    • Per RFC 4643 §2.3
    • Handled by proxy authentication layer

Variants§

§

AuthUser

Authentication: AUTHINFO USER RFC 4643 §2.3.1

§

AuthPass

Authentication: AUTHINFO PASS RFC 4643 §2.3.2

§

Stateful

Commands requiring GROUP context: article-by-number, NEXT, LAST, XOVER, etc. RFC 3977 §6.1

§

NonRoutable

Commands that cannot work with multiplexing: POST, IHAVE, NEWGROUPS, NEWNEWS RFC 3977 §6.3, RFC 3977 §7.3-7.4

§

Stateless

Safe to proxy without state: LIST, DATE, CAPABILITIES, HELP, QUIT, etc. RFC 3977 §7

§

ArticleByMessageId

Article retrieval by message-ID: ARTICLE/BODY/HEAD/STAT (70%+ of traffic) RFC 3977 §6.2

Implementations§

Source§

impl NntpCommand

Source

pub const fn is_stateful(&self) -> bool

Check if this command requires stateful session (for hybrid routing mode)

Returns true if the command requires a dedicated backend connection with maintained state (e.g., GROUP, XOVER, article-by-number).

Source

pub fn classify(command: &str) -> Self

Classify an NNTP command for routing/handling strategy

Analyzes the command string and returns the appropriate classification for proxy routing decisions.

§Performance Characteristics (40Gbit optimization)
  • Hot path (70%+ traffic): 4-6ns - ARTICLE/BODY/HEAD/STAT by message-ID
  • Zero allocations: Direct byte comparisons only
  • Branch predictor friendly: Most common commands checked first
§Traffic Distribution (typical NZB download workload)
  • 70%: ARTICLE/BODY/HEAD/STAT by message-ID → ArticleByMessageId
  • 10%: GROUP → Stateful
  • 5%: XOVER/OVER → Stateful
  • 5%: LIST/DATE/CAPABILITIES → Stateless
  • 5%: AUTHINFO → AuthUser/AuthPass
  • <5%: Everything else
§Algorithm
  1. Ultra-fast path: Check for article-by-message-ID in one pass (70%+ hit rate)
  2. Parse command: Split on first space per RFC 3977 §3.1
  3. Frequency-ordered matching: Check common commands before rare ones
§Case Insensitivity

Per RFC 3977 §3.1, commands are case-insensitive. We match against pre-computed literal variations (UPPER/lower/Title) for maximum performance.

Trait Implementations§

Source§

impl Debug for NntpCommand

Source§

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

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

impl PartialEq for NntpCommand

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for NntpCommand

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more