Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/bhttp/src/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  parse.rs

  Sprache: Rust
 

#[cfg(feature = "read-http")]
use crate::{Error, ReadSeek, Res};
#[cfg(feature = "read-http")]
use std::borrow::BorrowMut;

pub const HTAB: u8 = 0x09;
#[cfg(feature = "read-http")]
pub const NL: u8 = 0x0a;
#[cfg(feature = "read-http")]
pub const CR: u8 = 0x0d;
pub const SP: u8 = 0x20;
pub const COMMA: u8 = 0x2c;
#[cfg(feature = "read-http")]
pub const SLASH: u8 = 0x2f;
#[cfg(feature = "read-http")]
pub const COLON: u8 = 0x3a;
#[cfg(feature = "read-http")]
pub const SEMICOLON: u8 = 0x3b;

pub fn is_ows(x: u8) -> bool {
    x == SP || x == HTAB
}

pub fn trim_ows(v: &[u8]) -> &[u8] {
    for s in 0..v.len() {
        if !is_ows(v[s]) {
            for e in (s..v.len()).rev() {
                if !is_ows(v[e]) {
                    return &v[s..=e];
                }
            }
        }
    }
    &v[..0]
}

#[cfg(feature = "read-http")]
pub fn downcase(n: &mut [u8]) {
    for i in n {
        if *i >= 0x41 && *i <= 0x5a {
            *i += 0x20;
        }
    }
}

pub fn index_of(v: u8, line: &[u8]) -> Option<usize> {
    for (i, x) in line.iter().enumerate() {
        if *x == v {
            return Some(i);
        }
    }
    None
}

#[cfg(feature = "read-http")]
pub fn split_at(v: u8, mut line: Vec<u8>) -> Option<(Vec<u8>, Vec<u8>)> {
    index_of(v, &line).map(|i| {
        let tail = line.split_off(i + 1);
        let _ = line.pop();
        (line, tail)
    })
}

#[cfg(feature = "read-http")]
pub fn read_line<T, R>(r: &mut T) -> Res<Vec<u8>>
where
    T: BorrowMut<R> + ?Sized,
    R: ReadSeek + ?Sized,
{
    let mut buf = Vec::new();
    r.borrow_mut().read_until(NL, &mut buf)?;
    let tail = buf.pop();
    if tail != Some(NL) {
        return Err(Error::Truncated);
    }
    if buf.pop().ok_or(Error::Missing(CR))? == CR {
        Ok(buf)
    } else {
        Err(Error::Missing(CR))
    }
}

Messung V0.5 in Prozent
C=89 H=96 G=92

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.