Skip to main content

MarkerHeaderParser

Struct MarkerHeaderParser 

Source
pub struct MarkerHeaderParser;
Expand description

Parser for the RAR archive marker (signature) header.

Implementations§

Source§

impl MarkerHeaderParser

Source

pub const HEADER_SIZE: usize = 7

Size of the RAR4 marker header in bytes.

Source

pub fn detect_version(buffer: &[u8]) -> Result<RarVersion>

Detect RAR version from buffer without full parsing.

Returns RarVersion::Rar4 or RarVersion::Rar5 based on the signature bytes, or RarError::InvalidSignature if the buffer doesn’t start with a valid RAR signature.

use rar_stream::parsing::marker_header::MarkerHeaderParser;
use rar_stream::parsing::marker_header::RarVersion;

let rar4 = [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00];
assert_eq!(MarkerHeaderParser::detect_version(&rar4).unwrap(), RarVersion::Rar4);

let rar5 = [0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00];
assert_eq!(MarkerHeaderParser::detect_version(&rar5).unwrap(), RarVersion::Rar5);

assert!(MarkerHeaderParser::detect_version(b"not rar").is_err());
Source

pub fn parse(buffer: &[u8]) -> Result<MarkerHeader>

Parse marker header from buffer. The marker header is actually parsed as a generic RAR header. The “size” field tells us how many bytes this header consumes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.