Skip to main content

MimePayload

Struct MimePayload 

Source
pub struct MimePayload {
    pub kinds: SmallVec<[(MimeKind, Vec<u8>); 4]>,
}
Expand description

A MIME-typed multi-format payload.

Used by both the clipboard ([lumen-os-clipboard]) and drag-and-drop ([lumen-os-dnd]) - one payload can carry multiple representations of the same data (the convention shared by QMimeData and GdkContentProvider). Targets read whichever MIME they understand.

Fields§

§kinds: SmallVec<[(MimeKind, Vec<u8>); 4]>

Stored representations in author-insertion order; recipients pick the first kind they understand.

Implementations§

Source§

impl MimePayload

Source

pub fn new() -> Self

Empty payload, no entries.

Source

pub fn is_empty(&self) -> bool

True when this payload carries no entries.

Source

pub fn with(self, kind: MimeKind, bytes: Vec<u8>) -> Self

Push an (kind, bytes) entry. Returns self for builder-style chaining.

Source

pub fn get(&self, kind: &MimeKind) -> Option<&[u8]>

Look up the first entry matching kind. Returns None when not carried.

Source

pub fn has(&self, kind: &MimeKind) -> bool

True when this payload carries the named kind.

Source

pub fn text(&self) -> Option<String>

Convenience: read the text/plain entry as UTF-8, falling back to an empty string when the bytes aren’t valid UTF-8.

Source

pub fn uris(&self) -> Vec<String>

Convenience: read the text/uri-list entry, splitting on \r\n per RFC 2483 (lines starting with # are comments and skipped).

Trait Implementations§

Source§

impl Clone for MimePayload

Source§

fn clone(&self) -> MimePayload

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MimePayload

Source§

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

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

impl Default for MimePayload

Source§

fn default() -> MimePayload

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

impl From<&str> for MimePayload

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for MimePayload

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<PathBuf>> for MimePayload

Source§

fn from(paths: Vec<PathBuf>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for MimePayload

Source§

fn from(bytes: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MimePayload

Source§

fn eq(&self, other: &MimePayload) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MimePayload

Source§

impl StructuralPartialEq for MimePayload

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.