pub struct Mailcap { /* private fields */ }
Expand description
Meta representation of all available mailcap files and their combined lines.
Implementations
sourceimpl Mailcap
impl Mailcap
sourcepub fn new() -> Result<Mailcap, MailcapError>
pub fn new() -> Result<Mailcap, MailcapError>
Returns a combined mailcap from all available default files or a $MAILCAPS env. The default list (in ascending order of importance) includes:
/usr/local/etc/mailcap
/usr/etc/mailcap
/etc/mailcap
$HOME/.mailcap
Examples
let cap = Mailcap::new()?;
Errors
If there are no available mailcap files in the default locations or no $MAILCAPS env has
been set, or if the files or empty or contain no valid mailcap lines, MailcapError
will
be returned. The implementation is loose: as long as one file exists with at least one
valid mailcap line, the Result
will be Ok
.
sourcepub fn get(&self, key: &str) -> Option<&Entry>
pub fn get(&self, key: &str) -> Option<&Entry>
Given a specific mime-type value, will lookup if there is an existing mailcap entry for that type.
Examples
let cap = Mailcap::new()?;
if let Some(i) = cap.get("text/html") {
let command = i.viewer("/var/www/index.html");
assert_eq!(command, "qutebrowser '/var/www/index.html'");
}
Trait Implementations
impl StructuralPartialEq for Mailcap
Auto Trait Implementations
impl RefUnwindSafe for Mailcap
impl Send for Mailcap
impl Sync for Mailcap
impl Unpin for Mailcap
impl UnwindSafe for Mailcap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more