[−][src]Struct exifsd::MarkedData
Parses a standard dynamically-sized chuck from a JPEG file.
Not all markers in JPEG are followed by data, or even a data size. This only represents those markers that have data. Markers that are not followed by data include "Start of Image", "End of Image", and "Reset".
One marker, the "Start of Segment" marker, is followed by data, but then that data is also followed by entropy-encoded data that is unmarked.
Fields
marker: u8
data: &'a [u8]
Methods
impl<'a> MarkedData<'a>
[src]
pub fn parser<I: 'a>(
marker: impl Parser<Input = I, Output = u8> + 'a
) -> impl Parser<Input = I, Output = MarkedData<'a>> + 'a where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<I::Item, I::Range, I::Position>,
[src]
marker: impl Parser<Input = I, Output = u8> + 'a
) -> impl Parser<Input = I, Output = MarkedData<'a>> + 'a where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<I::Item, I::Range, I::Position>,
Parses out marked data from a JPEG file with marker parser marker
.
use exifsd::*; use combine::*; // 0xFF - Start of marker // 0x11 - Marker // 0x00, 0x03 - Length of data including length (so data length 1) // 0x01 - The data let input = &[0xFF, 0x11, 0x00, 0x03, 0x01][..]; let result = MarkedData::parser(token(0x11)).parse(input); let expected = MarkedData { marker: 0x11, data: &[0x01] }; assert_eq!(result, Ok((expected, &[][..]))); // Length cannot be less than 2 (here it is 1). MarkedData::parser(any()).parse(&[0xFF, 0x11, 0x00, 0x01][..]).unwrap_err();
pub fn write<W: WriteBytesExt>(&self, writer: &mut W) -> Result<()>
[src]
Writes the binary representation of the MarkedData
out to a file.
use exifsd::*; use combine::*; let input = &[0xFF, 0x11, 0x00, 0x03, 0x01][..]; let marked_data = MarkedData::parser(token(0x11)).parse(input).unwrap().0; let mut written = vec![]; marked_data.write(&mut written).unwrap(); assert_eq!(input, &written[..]);
Trait Implementations
impl<'a> Copy for MarkedData<'a>
[src]
impl<'a> PartialEq<MarkedData<'a>> for MarkedData<'a>
[src]
fn eq(&self, other: &MarkedData<'a>) -> bool
[src]
fn ne(&self, other: &MarkedData<'a>) -> bool
[src]
impl<'a> Clone for MarkedData<'a>
[src]
fn clone(&self) -> MarkedData<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Eq for MarkedData<'a>
[src]
impl<'a> Debug for MarkedData<'a>
[src]
Auto Trait Implementations
impl<'a> Send for MarkedData<'a>
impl<'a> Sync for MarkedData<'a>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,