exif::experimental

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

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.