[][src]Struct brokaw::types::response::BinaryArticle

pub struct BinaryArticle { /* fields omitted */ }

A binary Netnews article

A BinaryArticle is created by calling try_from with a RawResponse.

For text articles, consider converting this article into a TextArticle.

Implementation Notes

Articles aim to follow RFC 3977 as closely as possible while remaining ergonomic.

  1. Response parsing will fail if the header names are not UTF-8
  2. The header contents will be lossily converted to UTF-8
  3. There are no formatting constraints on the body

Implementations

impl BinaryArticle[src]

pub fn number(&self) -> ArticleNumber[src]

The number of the article relative to the group it was retrieved from

pub fn message_id(&self) -> &str[src]

The message id of the article

pub fn headers(&self) -> &Headers[src]

The headers on the article

pub fn body(&self) -> &[u8][src]

The raw contents of the body

pub fn lines_len(&self) -> usize[src]

The number of lines in the body

pub fn lines(&self) -> Lines[src]

An iterator over the lines in the body of the article

pub fn unterminated(&self) -> Unterminated[src]

An iterator over the lines of the body without the CRLF terminators

pub fn to_text(&self) -> Result<TextArticle>[src]

Convert the article into a TextArticle

This will return an error if the body is not valid UTF-8

pub fn to_text_lossy(&self) -> TextArticle[src]

Convert the article into a TextArticle including invalid characters.

This function is analogous to calling is String::from_utf8_lossy on every line in the body

Trait Implementations

impl Clone for BinaryArticle[src]

impl Debug for BinaryArticle[src]

impl Display for BinaryArticle[src]

impl Eq for BinaryArticle[src]

impl PartialEq<BinaryArticle> for BinaryArticle[src]

impl StructuralEq for BinaryArticle[src]

impl StructuralPartialEq for BinaryArticle[src]

impl<'_> TryFrom<&'_ RawResponse> for BinaryArticle[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(resp: &RawResponse) -> Result<Self>[src]

Convert a raw response into an article

For the specification see RFC 3977 sections:

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.