Skip to main content

Archive

Struct Archive 

Source
pub struct Archive { /* private fields */ }
Expand description

What the export export returns, as Archive::to_json, for a format whose manifest entry sets output = "archive": files Hammer zips in the order they were added.

A path is relative, with / between its segments: not empty, not starting with /, no \, no empty segment (so no // or trailing /), no . or .. segment, and not a path already added. Adding a file with any other path fails, naming it, as Hammer would refuse the reply.

Implementations§

Source§

impl Archive

Source

pub fn new() -> Archive

An archive without files.

Source

pub fn text( &mut self, path: impl Into<String>, text: impl Into<String>, ) -> Result<&mut Archive>

Adds text as the file at path, written as UTF-8.

Source

pub fn bytes( &mut self, path: impl Into<String>, bytes: &[u8], ) -> Result<&mut Archive>

Adds bytes as the file at path.

Source

pub fn base64( &mut self, path: impl Into<String>, encoded: impl Into<String>, ) -> Result<&mut Archive>

Adds the file at path whose bytes encoded holds as standard padded base64, passed on without decoding it, for base64 a plugin kept itself; Hammer fails the export when it is not base64.

Source

pub fn image( &mut self, path: impl Into<String>, image: impl ArchiveImage, ) -> Result<&mut Archive>

Adds an image of Request::images as the file at path, named by its id: 5 or &image. Hammer writes its bytes, so the reply carries none; an id it did not send fails the export.

Source

pub fn to_json(&self) -> Result<String>

The export export’s reply; fails when no file was added.

Trait Implementations§

Source§

impl Default for Archive

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.