Struct gdk4::ContentFormats[][src]

pub struct ContentFormats(_);
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 Gdk::ContentFormats::to_string()`` 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.

Implementations

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.

Creates a new ContentFormats for a given GType.

type_

a GType

Returns

a new ContentFormats

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

type_

the GType to search for

Returns

true if the GType was found

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

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.

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

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

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

Returns

a new ContentFormats

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

Returns

a new ContentFormats

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

Returns

a new ContentFormats

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

Returns

a new ContentFormats

This is supported on crate feature v4_4 only.

Parses the given string into ContentFormats and returns the formats.

Strings printed via Gdk::ContentFormats::to_string()`` 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

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.