[][src]Struct exifsd::ScanSegment

pub struct ScanSegment<'a> {
    pub specifier: &'a [u8],
    pub data: &'a [u8],
}

A Scan Segment is contains a segment of the JPEG data.

Fields

specifier: &'a [u8]

Specifies which segment is encoded following this specifier.

data: &'a [u8]

The actual entropy-encoded data that makes up the image segment.

Methods

impl<'a> ScanSegment<'a>[src]

pub fn parser<I: 'a>() -> impl Parser<Input = I, Output = ScanSegment<'a>> + 'a where
    I: RangeStream<Item = u8, Range = &'a [u8]>,
    I::Error: ParseError<I::Item, I::Range, I::Position>, 
[src]

Parses out a Scan Segment, including the entropy-encoded data.

use exifsd::*;
use combine::*;

let input = &[0xFF, 0xDA, 0x00, 0x02, 0x01, 0xFF, 0x00, 0x02, 0xFF, 0xFF, 0xD9][..];
let result = ScanSegment::parser().parse(input);
let expected = ScanSegment { specifier: &[], data: &[0x01, 0xFF, 0x00, 0x02, 0xFF] };

// Note that the marker `[0xFF, 0xD9]` is not consumed.
assert_eq!(result, Ok((expected, &[0xFF, 0xD9][..])));

pub fn write<W: WriteBytesExt>(&self, writer: &mut W) -> Result<()>[src]

Writes the binary representation of the ScanSegment out to a file.

use exifsd::*;
use combine::*;

let input = &[0xFF, 0xDA, 0x00, 0x02, 0x01, 0xFF, 0x00, 0x02][..];
let scan_segment = ScanSegment::parser().parse(input).unwrap().0;
let mut written = vec![];
scan_segment.write(&mut written).unwrap();
assert_eq!(input, &written[..]);

Trait Implementations

impl<'a> Copy for ScanSegment<'a>[src]

impl<'a> PartialEq<ScanSegment<'a>> for ScanSegment<'a>[src]

impl<'a> Clone for ScanSegment<'a>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> Eq for ScanSegment<'a>[src]

impl<'a> Debug for ScanSegment<'a>[src]

Auto Trait Implementations

impl<'a> Send for ScanSegment<'a>

impl<'a> Sync for ScanSegment<'a>

Blanket Implementations

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

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

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.