gdk4

Struct ContentFormats

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

The ContentFormats structure is used to advertise and negotiate the format of content.

You will encounter ContentFormats when interacting with objects controlling operations that pass data between different widgets, window or application, like Drag, Drop, Clipboard or ContentProvider.

GDK supports content in 2 forms: GType and mime type. Using GTypes is meant only for in-process content transfers. Mime types are meant to be used for data passing both in-process and out-of-process. The details of how data is passed is described in the documentation of the actual implementations. To transform between the two forms, ContentSerializer and ContentDeserializer are used.

A ContentFormats describes a set of possible formats content can be exchanged in. It is assumed that this set is ordered. GTypes are more important than mime types. Order between different GTypes or mime types is the order they were added in, most important first. Functions that care about order, such as union(), will describe in their documentation how they interpret that order, though in general the order of the first argument is considered the primary order of the result, followed by the order of further arguments.

For debugging purposes, the function to_str() exists. It will print a comma-separated list of formats from most important to least important.

ContentFormats is an immutable struct. After creation, you cannot change the types it represents. Instead, new ContentFormats have to be created. The ContentFormatsBuilder structure is meant to help in this endeavor.

GLib type: Shared boxed type with reference counted clone semantics.

Implementations§

Source§

impl ContentFormats

Source

pub fn as_ptr(&self) -> *mut GdkContentFormats

Return the inner pointer to the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GdkContentFormats) -> &Self

Borrows the underlying C value.

Source§

impl ContentFormats

Source

pub fn new(mime_types: &[&str]) -> ContentFormats

Creates a new ContentFormats from an array of mime types.

The mime types must be valid and different from each other or the behavior of the return value is undefined. If you cannot guarantee this, use ContentFormatsBuilder instead.

§mime_types

Pointer to an array of mime types

§Returns

the new ContentFormats.

Source

pub fn for_type(type_: Type) -> ContentFormats

Creates a new ContentFormats for a given GType.

§type_

a GType

§Returns

a new ContentFormats

Source

pub fn contains_type(&self, type_: Type) -> bool

Checks if a given GType is part of the given @self.

§type_

the GType to search for

§Returns

true if the GType was found

Source

pub fn contain_mime_type(&self, mime_type: &str) -> bool

Checks if a given mime type is part of the given @self.

§mime_type

the mime type to search for

§Returns

true if the mime_type was found

Source

pub fn mime_types(&self) -> Vec<GString>

Gets the mime types included in @self.

Note that @self may not contain any mime types, in particular when they are empty. In that case None will be returned.

§Returns

None-terminated array of interned strings of mime types included in @self

Source

pub fn is_empty(&self) -> bool

Available on crate feature v4_18 only.

Returns whether the content formats contain any formats.

§Returns

true if @self contains no mime types and no GTypes

Source

pub fn match_(&self, second: &ContentFormats) -> bool

Checks if @self and @second have any matching formats.

§second

the ContentFormats to intersect with

§Returns

true if a matching format was found.

Source

pub fn match_type(&self, second: &ContentFormats) -> Type

Finds the first GType from @self that is also contained in @second.

If no matching GType is found, G_TYPE_INVALID is returned.

§second

the ContentFormats to intersect with

§Returns

The first common GType or G_TYPE_INVALID if none.

Source

pub fn match_mime_type(&self, second: &ContentFormats) -> Option<GString>

Finds the first mime type from @self that is also contained in @second.

If no matching mime type is found, None is returned.

§second

the ContentFormats to intersect with

§Returns

The first common mime type or None if none

Source

pub fn to_str(&self) -> GString

Prints the given @self into a human-readable string.

The resulting string can be parsed with parse().

This is a small wrapper around Gdk::ContentFormats::print() to help when debugging.

§Returns

a new string

Source

pub fn union(self, second: &ContentFormats) -> ContentFormats

Append all missing types from @second to @self, in the order they had in @second.

§second

the ContentFormats to merge from

§Returns

a new ContentFormats

Source

pub fn union_deserialize_types(self) -> ContentFormats

Add GTypes for mime types in @self for which deserializers are registered.

§Returns

a new ContentFormats

Source

pub fn union_deserialize_mime_types(self) -> ContentFormats

Add mime types for GTypes in @self for which deserializers are registered.

§Returns

a new ContentFormats

Source

pub fn union_serialize_types(self) -> ContentFormats

Add GTypes for the mime types in @self for which serializers are registered.

§Returns

a new ContentFormats

Source

pub fn union_serialize_mime_types(self) -> ContentFormats

Add mime types for GTypes in @self for which serializers are registered.

§Returns

a new ContentFormats

Source

pub fn parse(string: &str) -> Result<ContentFormats, BoolError>

Available on crate feature v4_4 only.

Parses the given @string into ContentFormats and returns the formats.

Strings printed via to_str() can be read in again successfully using this function.

If @string does not describe valid content formats, None is returned.

§string

the string to parse

§Returns

the content formats if @string is valid

Source§

impl ContentFormats

Source

pub fn types(&self) -> Slice<Type>

Gets the GTypes included in @self.

Note that @self may not contain any GTypes, in particular when they are empty. In that case None will be returned.

§Returns

G_TYPE_INVALID-terminated array of types included in @self

Source

pub fn builder() -> ContentFormatsBuilder

Creates a new builder-pattern struct instance to construct ContentFormats objects.

This method returns an instance of ContentFormatsBuilder which can be used to create ContentFormats objects.

Trait Implementations§

Source§

impl Clone for ContentFormats

Source§

fn clone(&self) -> Self

Makes a clone of this shared reference.

This increments the strong reference count of the reference. Dropping the reference will decrement it again.

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentFormats

Source§

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

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

impl Display for ContentFormats

Source§

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

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

impl From<ContentFormats> for Value

Source§

fn from(s: ContentFormats) -> Self

Converts to this type from the input type.
Source§

impl FromStr for ContentFormats

Available on crate feature v4_4 only.
Source§

type Err = BoolError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl HasParamSpec for ContentFormats

Source§

type ParamSpec = ParamSpecBoxed

Source§

type SetValue = ContentFormats

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, ContentFormats>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl Hash for ContentFormats

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for ContentFormats

Source§

fn cmp(&self, other: &ContentFormats) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ContentFormats

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd for ContentFormats

Source§

fn partial_cmp(&self, other: &ContentFormats) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for ContentFormats

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq for ContentFormats

Source§

impl StructuralPartialEq for ContentFormats

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

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> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

Ensures that the type has been registered with the type system.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TransparentType for T

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> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

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.
Source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,