pub struct ScanSegment<'a> {
pub specifier: &'a [u8],
pub data: &'a [u8],
}
Expand description
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.
Implementations§
Source§impl<'a> ScanSegment<'a>
impl<'a> ScanSegment<'a>
Sourcepub fn parser<I>() -> impl Parser<Input = I, Output = ScanSegment<'a>> + 'awhere
I: RangeStream<Item = u8, Range = &'a [u8]> + 'a,
I::Error: ParseError<I::Item, I::Range, I::Position>,
pub fn parser<I>() -> impl Parser<Input = I, Output = ScanSegment<'a>> + 'awhere
I: RangeStream<Item = u8, Range = &'a [u8]> + 'a,
I::Error: ParseError<I::Item, I::Range, I::Position>,
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][..])));
Sourcepub fn write<W: WriteBytesExt>(&self, writer: &mut W) -> Result<()>
pub fn write<W: WriteBytesExt>(&self, writer: &mut W) -> Result<()>
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§
Source§impl<'a> Clone for ScanSegment<'a>
impl<'a> Clone for ScanSegment<'a>
Source§fn clone(&self) -> ScanSegment<'a>
fn clone(&self) -> ScanSegment<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for ScanSegment<'a>
impl<'a> Debug for ScanSegment<'a>
Source§impl<'a> PartialEq for ScanSegment<'a>
impl<'a> PartialEq for ScanSegment<'a>
impl<'a> Copy for ScanSegment<'a>
impl<'a> Eq for ScanSegment<'a>
impl<'a> StructuralPartialEq for ScanSegment<'a>
Auto Trait Implementations§
impl<'a> Freeze for ScanSegment<'a>
impl<'a> RefUnwindSafe for ScanSegment<'a>
impl<'a> Send for ScanSegment<'a>
impl<'a> Sync for ScanSegment<'a>
impl<'a> Unpin for ScanSegment<'a>
impl<'a> UnwindSafe for ScanSegment<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more