Camel.DataWrapper

g Camel.DataWrapper Camel.DataWrapper GObject.Object GObject.Object GObject.Object->Camel.DataWrapper

Subclasses:

Camel.Medium, Camel.Multipart

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

calculate_decoded_size_sync (cancellable)

calculate_size_sync (cancellable)

construct_from_data_sync (data, data_len, cancellable)

construct_from_input_stream (input_stream, io_priority, cancellable, callback, *user_data)

construct_from_input_stream_finish (result)

construct_from_input_stream_sync (input_stream, cancellable)

construct_from_stream (stream, io_priority, cancellable, callback, *user_data)

construct_from_stream_finish (result)

construct_from_stream_sync (stream, cancellable)

decode_to_output_stream (output_stream, io_priority, cancellable, callback, *user_data)

decode_to_output_stream_finish (result)

decode_to_output_stream_sync (output_stream, cancellable)

decode_to_stream (stream, io_priority, cancellable, callback, *user_data)

decode_to_stream_finish (result)

decode_to_stream_sync (stream, cancellable)

get_byte_array ()

get_encoding ()

get_mime_type ()

get_mime_type_field ()

is_offline ()

set_encoding (encoding)

set_mime_type (mime_type)

set_mime_type_field (mime_type)

set_offline (offline)

take_mime_type_field (mime_type)

write_to_output_stream (output_stream, io_priority, cancellable, callback, *user_data)

write_to_output_stream_finish (result)

write_to_output_stream_sync (output_stream, cancellable)

write_to_stream (stream, io_priority, cancellable, callback, *user_data)

write_to_stream_finish (result)

write_to_stream_sync (stream, cancellable)

Virtual Methods

Inherited:

GObject.Object (7)

do_construct_from_input_stream_sync (input_stream, cancellable)

do_construct_from_stream_sync (stream, cancellable)

do_decode_to_output_stream_sync (output_stream, cancellable)

do_decode_to_stream_sync (stream, cancellable)

do_get_mime_type ()

do_get_mime_type_field ()

do_is_offline ()

do_set_mime_type (mime_type)

do_set_mime_type_field (mime_type)

do_write_to_output_stream_sync (output_stream, cancellable)

do_write_to_stream_sync (stream, cancellable)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class Camel.DataWrapper(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Camel.DataWrapperClass

classmethod new()
Returns:

a new Camel.DataWrapper object

Return type:

Camel.DataWrapper

Create a new Camel.DataWrapper object.

calculate_decoded_size_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable, or None

Raises:

GLib.Error

Returns:

how many bytes the self would use when saved, or -1 on error.

Return type:

int

Calculates decoded size of the self by saving it to a null-stream and returns how many bytes had been written. It’s using Camel.DataWrapper.decode_to_stream_sync() internally.

New in version 3.24.

calculate_size_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable, or None

Raises:

GLib.Error

Returns:

how many bytes the self would use when saved, or -1 on error.

Return type:

int

Calculates size of the self by saving it to a null-stream and returns how many bytes had been written. It’s using Camel.DataWrapper.write_to_stream_sync() internally.

New in version 3.24.

construct_from_data_sync(data, data_len, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True on success, False on error

Return type:

bool

Constructs the content of self from data of length data_len.

New in version 3.46.

construct_from_input_stream(input_stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously constructs the content of self from input_stream.

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.construct_from_input_stream_finish() to get the result of the operation.

New in version 3.12.

construct_from_input_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True on success, False on error

Return type:

bool

Finishes the operation started with Camel.DataWrapper.construct_from_input_stream().

New in version 3.12.

construct_from_input_stream_sync(input_stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True on success, False on error

Return type:

bool

Constructs the content of self from input_stream.

New in version 3.12.

construct_from_stream(stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously constructs the content of self from the given stream.

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.construct_from_stream_finish() to get the result of the operation.

New in version 3.0.

construct_from_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True on success, False on error

Return type:

bool

Finishes the operation started with Camel.DataWrapper.construct_from_stream().

New in version 3.0.

construct_from_stream_sync(stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True on success, False on error

Return type:

bool

Constructs the content of self from the given stream.

New in version 3.0.

decode_to_output_stream(output_stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously writes the decoded data content to output_stream.

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.decode_to_output_stream_finish() to get the result of the operation.

New in version 3.12.

decode_to_output_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Finishes the operation started with Camel.DataWrapper.decode_to_output_stream().

New in version 3.12.

decode_to_output_stream_sync(output_stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the decoded data content to output_stream.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to output_stream.

New in version 3.12.

decode_to_stream(stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously writes the decoded data content to stream.

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.decode_to_stream_finish() to get the result of the operation.

New in version 3.0.

decode_to_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Finishes the operation started with Camel.DataWrapper.decode_to_stream().

New in version 3.0.

decode_to_stream_sync(stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the decoded data content to stream.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to stream.

New in version 3.0.

get_byte_array()
Returns:

the GLib.ByteArray for self

Return type:

bytes

Returns the GLib.ByteArray being used to hold the contents of self.

Note, it’s up to the caller to use this in a thread-safe manner.

New in version 3.2.

get_encoding()
Returns:

An encoding (Camel.TransferEncoding) of the self

Return type:

Camel.TransferEncoding

New in version 3.24.

get_mime_type()
Returns:

the MIME type which must be freed by the caller

Return type:

str

get_mime_type_field()
Returns:

the parsed form of the data wrapper’s MIME type

Return type:

Camel.ContentType or None

is_offline()
Returns:

whether self is “offline” (data stored remotely) or not. Some optional code paths may choose to not operate on offline data.

Return type:

bool

set_encoding(encoding)
Parameters:

encoding (Camel.TransferEncoding) – an encoding to set

Sets encoding (Camel.TransferEncoding) for the self. It doesn’t re-encode the content, if the encoding changes.

New in version 3.24.

set_mime_type(mime_type)
Parameters:

mime_type (str) – a MIME type

This sets the data wrapper’s MIME type.

It might fail, but you won’t know. It will allow you to set Content-Type parameters on the data wrapper, which are meaningless. You should not be allowed to change the MIME type of a data wrapper that contains data, or at least, if you do, it should invalidate the data.

set_mime_type_field(mime_type)
Parameters:

mime_type (Camel.ContentType or None) – a Camel.ContentType

This sets the data wrapper’s MIME type. It adds its own reference to mime_type, if not None.

It suffers from the same flaws as Camel.DataWrapper.set_mime_type().

set_offline(offline)
Parameters:

offline (bool) – whether the self is “offline”

Sets whether the self is “offline”. It applies only to this concrete instance. See Camel.DataWrapper.is_offline().

New in version 3.24.

take_mime_type_field(mime_type)
Parameters:

mime_type (Camel.ContentType or None) – a Camel.ContentType

Sets mime-type filed to be mime_type and consumes it, aka unlike Camel.DataWrapper.set_mime_type_field(), this doesn’t add its own reference to mime_type.

It suffers from the same flaws as Camel.DataWrapper.set_mime_type().

New in version 3.24.

write_to_output_stream(output_stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously writes the content of self to output_stream in a machine-independent format appropriate for the data.

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.write_to_output_stream_finish() to get the result of the operation.

New in version 3.12.

write_to_output_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Finishes the operation started with Camel.DataWrapper.write_to_output_stream().

New in version 3.12.

write_to_output_stream_sync(output_stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the content of self to output_stream in a machine-independent format appropriate for the data.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to output_stream.

New in version 3.12.

write_to_stream(stream, io_priority, cancellable, callback, *user_data)
Parameters:

Asynchronously writes the content of self to stream in a machine-independent format appropriate for the data. It should be possible to construct an equivalent data wrapper object later by passing this stream to Camel.DataWrapper.construct_from_stream().

When the operation is finished, callback will be called. You can then call Camel.DataWrapper.write_to_stream_finish() to get the result of the operation.

New in version 3.0.

write_to_stream_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

the number of bytes written, or -1 or error

Return type:

int

Finishes the operation started with Camel.DataWrapper.write_to_stream().

New in version 3.0.

write_to_stream_sync(stream, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the content of self to stream in a machine-independent format appropriate for the data. It should be possible to construct an equivalent data wrapper object later by passing this stream to Camel.DataWrapper.construct_from_stream_sync().

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to stream.

New in version 3.0.

do_construct_from_input_stream_sync(input_stream, cancellable) virtual
Parameters:
Returns:

True on success, False on error

Return type:

bool

Constructs the content of data_wrapper from input_stream.

New in version 3.12.

do_construct_from_stream_sync(stream, cancellable) virtual
Parameters:
Returns:

True on success, False on error

Return type:

bool

Constructs the content of data_wrapper from the given stream.

New in version 3.0.

do_decode_to_output_stream_sync(output_stream, cancellable) virtual
Parameters:
Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the decoded data content to output_stream.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to output_stream.

New in version 3.12.

do_decode_to_stream_sync(stream, cancellable) virtual
Parameters:
Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the decoded data content to stream.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to stream.

New in version 3.0.

do_get_mime_type() virtual
Returns:

the MIME type which must be freed by the caller

Return type:

str

do_get_mime_type_field() virtual
Returns:

the parsed form of the data wrapper’s MIME type

Return type:

Camel.ContentType or None

do_is_offline() virtual
Returns:

whether data_wrapper is “offline” (data stored remotely) or not. Some optional code paths may choose to not operate on offline data.

Return type:

bool

do_set_mime_type(mime_type) virtual
Parameters:

mime_type (str) – a MIME type

This sets the data wrapper’s MIME type.

It might fail, but you won’t know. It will allow you to set Content-Type parameters on the data wrapper, which are meaningless. You should not be allowed to change the MIME type of a data wrapper that contains data, or at least, if you do, it should invalidate the data.

do_set_mime_type_field(mime_type) virtual
Parameters:

mime_type (Camel.ContentType or None) – a Camel.ContentType

This sets the data wrapper’s MIME type. It adds its own reference to mime_type, if not None.

It suffers from the same flaws as Camel.DataWrapper.set_mime_type().

do_write_to_output_stream_sync(output_stream, cancellable) virtual
Parameters:
Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the content of data_wrapper to output_stream in a machine-independent format appropriate for the data.

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to output_stream.

New in version 3.12.

do_write_to_stream_sync(stream, cancellable) virtual
Parameters:
Returns:

the number of bytes written, or -1 on error

Return type:

int

Writes the content of data_wrapper to stream in a machine-independent format appropriate for the data. It should be possible to construct an equivalent data wrapper object later by passing this stream to Camel.DataWrapper.construct_from_stream_sync().

This function may block even if the given output stream does not. For example, the content may have to be fetched across a network before it can be written to stream.

New in version 3.0.