pub struct Article<'a> {
pub message_id: MessageId<'a>,
pub article_number: Option<u64>,
pub headers: Option<Headers<'a>>,
pub body: Option<&'a [u8]>,
}Expand description
Parsed NNTP article response (zero-copy)
Different response codes populate different fields:
- 220 ARTICLE: headers + body
- 221 HEAD: headers only
- 222 BODY: body only
- 223 STAT: neither (just metadata)
Fields§
§message_id: MessageId<'a>§article_number: Option<u64>§headers: Option<Headers<'a>>§body: Option<&'a [u8]>Implementations§
Source§impl<'a> Article<'a>
impl<'a> Article<'a>
Sourcepub fn parse(buf: &'a [u8], validate_yenc: bool) -> Result<Self, ParseError>
pub fn parse(buf: &'a [u8], validate_yenc: bool) -> Result<Self, ParseError>
Parse NNTP article response with optional yEnc validation
§Arguments
buf- Complete response bytes from the session response reader.validate_yenc- Whether to validate yEnc structure/checksums
§Errors
Returns ParseError when the NNTP response status line, message metadata,
headers, body structure, or optional yEnc validation fails.
Sourcepub fn decode(&self) -> Option<Vec<u8>>
pub fn decode(&self) -> Option<Vec<u8>>
Decode yEnc-encoded body to raw bytes
This method allocates a new Vec<u8> for each call. For hot paths where
articles are frequently decoded, prefer Article::decode_into to
reuse a caller-provided buffer and avoid per-call allocations.
§Returns
Decoded bytes, or None if body is not yEnc-encoded
Sourcepub fn decode_into(&self, output: &mut Vec<u8>) -> bool
pub fn decode_into(&self, output: &mut Vec<u8>) -> bool
Decode yEnc-encoded body into the provided buffer
This method reuses the capacity of output and performs no allocations
if the buffer is already large enough, making it suitable for hot paths.
§Behavior
- Returns
falseif:- The article has no body, or
- The body is not yEnc-encoded (does not start with
=ybegin)
- Returns
trueand writes the decoded bytes intooutputotherwise.
On success, output is cleared before writing the decoded bytes.
Trait Implementations§
impl<'a> Eq for Article<'a>
impl<'a> StructuralPartialEq for Article<'a>
Auto Trait Implementations§
impl<'a> Freeze for Article<'a>
impl<'a> RefUnwindSafe for Article<'a>
impl<'a> Send for Article<'a>
impl<'a> Sync for Article<'a>
impl<'a> Unpin for Article<'a>
impl<'a> UnsafeUnpin for Article<'a>
impl<'a> UnwindSafe for Article<'a>
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.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