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
Implementations§
Source§impl NntpCommand
impl NntpCommand
Sourcepub const fn is_stateful(&self) -> bool
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).
Sourcepub fn parse(command: &str) -> Self
pub fn parse(command: &str) -> Self
Parse 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
- Ultra-fast path: Check for article-by-message-ID in one pass (70%+ hit rate)
- Per RFC 3977 §6.2
- Parse command: Split on first space per RFC 3977 §3.1
- 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
impl Debug for NntpCommand
Source§impl PartialEq for NntpCommand
impl PartialEq for NntpCommand
impl StructuralPartialEq for NntpCommand
Auto Trait Implementations§
impl Freeze for NntpCommand
impl RefUnwindSafe for NntpCommand
impl Send for NntpCommand
impl Sync for NntpCommand
impl Unpin for NntpCommand
impl UnwindSafe for NntpCommand
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more