Struct exif::experimental::Writer

source ·
pub struct Writer<'a> { /* private fields */ }
Expand description

The Writer struct is used to encode and write Exif data.

§Examples

use exif::{Field, In, Tag, Value};
use exif::experimental::Writer;
let image_desc = Field {
    tag: Tag::ImageDescription,
    ifd_num: In::PRIMARY,
    value: Value::Ascii(vec![b"Sample".to_vec()]),
};
let mut writer = Writer::new();
let mut buf = std::io::Cursor::new(Vec::new());
writer.push_field(&image_desc);
writer.write(&mut buf, false)?;
static expected: &[u8] =
    b"\x4d\x4d\x00\x2a\x00\x00\x00\x08\
      \x00\x01\x01\x0e\x00\x02\x00\x00\x00\x07\x00\x00\x00\x1a\
      \x00\x00\x00\x00\
      Sample\0";
assert_eq!(buf.into_inner(), expected);

Implementations§

source§

impl<'a> Writer<'a>

source

pub fn new() -> Writer<'a>

Constructs an empty Writer.

source

pub fn push_field(&mut self, field: &'a Field)

Appends a field to be written.

The fields can be appended in any order. Duplicate fields must not be appended.

The following fields are ignored and synthesized when needed: ExifIFDPointer, GPSInfoIFDPointer, InteropIFDPointer, StripOffsets, StripByteCounts, TileOffsets, TileByteCounts, JPEGInterchangeFormat, and JPEGInterchangeFormatLength.

source

pub fn set_strips(&mut self, strips: &'a [&'a [u8]], ifd_num: In)

Sets TIFF strips for the specified IFD. If this method is called multiple times, the last one is used.

source

pub fn set_tiles(&mut self, tiles: &'a [&'a [u8]], ifd_num: In)

Sets TIFF tiles for the specified IFD. If this method is called multiple times, the last one is used.

source

pub fn set_jpeg(&mut self, jpeg: &'a [u8], ifd_num: In)

Sets JPEG data for the specified IFD. If this method is called multiple times, the last one is used.

source

pub fn write<W>(&mut self, w: &mut W, little_endian: bool) -> Result<(), Error>
where W: Write + Seek,

Encodes Exif data and writes it into w.

The write position of w must be set to zero before calling this method.

Trait Implementations§

source§

impl<'a> Debug for Writer<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Writer<'a>

§

impl<'a> RefUnwindSafe for Writer<'a>

§

impl<'a> Send for Writer<'a>

§

impl<'a> Sync for Writer<'a>

§

impl<'a> Unpin for Writer<'a>

§

impl<'a> UnwindSafe for Writer<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.