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
impl Command
Sourcepub fn new() -> Self
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.
Sourcepub fn arg<S>(&mut self, arg: S) -> Result<&mut Self>
pub fn arg<S>(&mut self, arg: S) -> Result<&mut Self>
Add a single argument.
For more information, examples, and errors, see Command.
Sourcepub fn args<I>(&mut self, args: I) -> Result<&mut Self>
pub fn args<I>(&mut self, args: I) -> Result<&mut Self>
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.
Sourcepub fn args_slice<S>(&mut self, args: &[S]) -> Result<&mut Self>
pub fn args_slice<S>(&mut self, args: &[S]) -> Result<&mut Self>
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.
Sourcepub fn gs<S>(&mut self, gs: S) -> Result<&mut Self>
pub fn gs<S>(&mut self, gs: S) -> Result<&mut Self>
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()?;