pub trait OutputStreamExtManual: Sized + OutputStreamExt {
    // Required methods
    fn write_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + 'static, C: IsA<Cancellable>>(
        &self,
        buffer: B,
        io_priority: Priority,
        cancellable: Option<&C>,
        callback: Q
    );
    fn write_all<C: IsA<Cancellable>>(
        &self,
        buffer: &[u8],
        cancellable: Option<&C>
    ) -> Result<(usize, Option<Error>), Error>;
    fn write_all_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option<Error>), (B, Error)>) + 'static, C: IsA<Cancellable>>(
        &self,
        buffer: B,
        io_priority: Priority,
        cancellable: Option<&C>,
        callback: Q
    );
    fn write_future<B: AsRef<[u8]> + Send + 'static>(
        &self,
        buffer: B,
        io_priority: Priority
    ) -> Pin<Box<dyn Future<Output = Result<(B, usize), (B, Error)>> + 'static>>;
    fn write_all_future<B: AsRef<[u8]> + Send + 'static>(
        &self,
        buffer: B,
        io_priority: Priority
    ) -> Pin<Box<dyn Future<Output = Result<(B, usize, Option<Error>), (B, Error)>> + 'static>>;

    // Provided method
    fn into_write(self) -> OutputStreamWrite<Self> 
       where Self: IsA<OutputStream> { ... }
}

Required Methods§

source

fn write_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q )

Request an asynchronous write of count bytes from buffer into the stream. When the operation is finished callback will be called. You can then call g_output_stream_write_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in IOErrorEnum::Pending errors.

A value of count larger than G_MAXSSIZE will cause a IOErrorEnum::InvalidArgument error.

On success, the number of bytes written will be passed to the callback. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested.

You are guaranteed that this method will never fail with IOErrorEnum::WouldBlock - if self can’t accept more data, the method will just wait until this changes.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is G_PRIORITY_DEFAULT.

The asynchronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

For the synchronous, blocking version of this function, see OutputStreamExt::write().

Note that no copy of buffer will be made, so it must stay valid until callback is called. See OutputStreamExt::write_bytes_async() for a glib::Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.

buffer

the buffer containing the data to write.

io_priority

the io priority of the request.

cancellable

optional Cancellable object, None to ignore.

callback

callback to call when the request is satisfied

source

fn write_all<C: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&C> ) -> Result<(usize, Option<Error>), Error>

Tries to write count bytes from buffer into the stream. Will block during the operation.

This function is similar to OutputStreamExt::write(), except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of count bytes, true is returned, and bytes_written is set to count.

If there is an error during the operation false is returned and error is set to indicate the error status.

As a special exception to the normal conventions for functions that use glib::Error, if this function returns false (and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around OutputStreamExt::write().

buffer

the buffer containing the data to write.

cancellable

optional Cancellable object, None to ignore.

Returns

true on success, false if there was an error

bytes_written

location to store the number of bytes that was written to the stream

source

fn write_all_async<B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option<Error>), (B, Error)>) + 'static, C: IsA<Cancellable>>( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q )

Request an asynchronous write of count bytes from buffer into the stream. When the operation is finished callback will be called. You can then call g_output_stream_write_all_finish() to get the result of the operation.

This is the asynchronous version of OutputStreamExtManual::write_all().

Call g_output_stream_write_all_finish() to collect the result.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is G_PRIORITY_DEFAULT.

Note that no copy of buffer will be made, so it must stay valid until callback is called.

buffer

the buffer containing the data to write

io_priority

the io priority of the request

cancellable

optional Cancellable object, None to ignore

callback

callback to call when the request is satisfied

source

fn write_future<B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(B, usize), (B, Error)>> + 'static>>

source

fn write_all_future<B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority ) -> Pin<Box<dyn Future<Output = Result<(B, usize, Option<Error>), (B, Error)>> + 'static>>

Provided Methods§

source

fn into_write(self) -> OutputStreamWrite<Self> where Self: IsA<OutputStream>,

Implementors§