Command

Struct Command 

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

Command builder for generic pstoedit interaction.

Commands are the main way to interact with pstoedit. A command is typically constructed using arg, args and/or args_slice. It can be run using run, multiple times if necessary.

§Examples

use pstoedit::Command;

pstoedit::init()?;
Command::new().arg("-gstest")?.run()?;
use pstoedit::Command;

pstoedit::init()?;
Command::new().args_slice(&["-f", "latex2e", "input.ps", "output.tex"])?.run()?;

§Errors

Most methods can raise NulError if a passed string contains an internal nul byte. Only run can raise different errors.

Implementations§

Source§

impl Command

Source

pub fn new() -> Self

Create a command with program name and without arguments.

The program name is already set in this function and should not be set using arg, args, or args_slice.

Source

pub fn arg<S>(&mut self, arg: S) -> Result<&mut Self>
where S: Into<Vec<u8>>,

Add a single argument.

For more information, examples, and errors, see Command.

Source

pub fn args<I>(&mut self, args: I) -> Result<&mut Self>
where I: IntoIterator, I::Item: Into<Vec<u8>>,

Add multiple arguments.

§Examples
use pstoedit::Command;

pstoedit::init()?;
Command::new().args(std::env::args().skip(1))?.run()?;
§Errors

NulError if a passed string contains an internal nul byte. Only the arguments before this string will have been added. Ownership of these later arguments will not be returned, consider using arg if necessary for more control.

Source

pub fn args_slice<S>(&mut self, args: &[S]) -> Result<&mut Self>
where S: AsRef<str>,

Add multiple arguments from slice.

Ownership of arguments is not passed for ergonomic reasons. If the potential optimization benefits of passing ownership are desired, use args or arg. This can be the case when passing instances of String or Vec<u8>.

§Examples

See Command.

§Errors

NulError if a passed string contains an internal nul byte. Only the arguments before this string will have been added.

Source

pub fn gs<S>(&mut self, gs: S) -> Result<&mut Self>
where S: Into<Vec<u8>>,

Specify ghostscript executable.

By default pstoedit tries to automatically determine this value. The specifics of this are platform-dependent.

§Examples
use pstoedit::Command;

pstoedit::init()?;
// Use personal ghostscript executable that is not in PATH
let gs = "/home/user/projects/ghostscript/bin/gs";
Command::new().arg("-gstest")?.gs(gs)?.run()?;
Source

pub fn run(&self) -> Result<()>

Run the command.

This can be done multiple times for the same Command.

§Examples

See Command.

§Errors

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Command

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.