titanite 0.3.0

Client/Server Library for Gemini protocol with Titan support
Documentation
pub trait Header {
    fn header_bytes(&self) -> Result<&[u8]>;
}

impl Header for &[u8] {
    fn header_bytes(&self) -> Result<&[u8]> {
        match self.iter().position(|&b| b == b'\r') {
            Some(n) => {
                if n > crate::HEADER_MAX_LEN {
                    bail!("Header bytes length reached")
                }
                if self.get(n + 1).is_some_and(|&b| b == b'\n') {
                    Ok(&self[..n])
                } else {
                    bail!("LF byte not found")
                }
            }
            None => bail!("CR byte not found"),
        }
    }
}

use anyhow::{bail, Result};