gi-gio-2.0.32: Gio bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.Gio.Objects.MemoryOutputStream

Contents

- Exported types
- Methods
  - getData
  - getDataSize
  - getSize
  - newResizable
  - stealAsBytes
  - stealData
- Properties
  - data
  - dataSize
  - size

Description

`GMemoryOutputStream` is a class for using arbitrary memory chunks as output for GIO streaming output operations.

As of GLib 2.34, `GMemoryOutputStream` trivially implements `PollableOutputStream`: it always polls as ready.

Synopsis

- newtype MemoryOutputStream = MemoryOutputStream (ManagedPtr MemoryOutputStream)
- class (GObject o, IsDescendantOf MemoryOutputStream o) => IsMemoryOutputStream o
- toMemoryOutputStream :: (MonadIO m, IsMemoryOutputStream o) => o -> m MemoryOutputStream
- memoryOutputStreamGetData :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m (Ptr ())
- memoryOutputStreamGetDataSize :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Word64
- memoryOutputStreamGetSize :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Word64
- memoryOutputStreamNewResizable :: (HasCallStack, MonadIO m) => m MemoryOutputStream
- memoryOutputStreamStealAsBytes :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m Bytes
- memoryOutputStreamStealData :: (HasCallStack, MonadIO m, IsMemoryOutputStream a) => a -> m (Ptr ())
- constructMemoryOutputStreamData :: (IsMemoryOutputStream o, MonadIO m) => Ptr () -> m (GValueConstruct o)
- getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ())
- getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong
- constructMemoryOutputStreamSize :: (IsMemoryOutputStream o, MonadIO m) => CULong -> m (GValueConstruct o)
- getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong

# Exported types

newtype MemoryOutputStream Source #

Memory-managed wrapper type.

Constructors

MemoryOutputStream (ManagedPtr MemoryOutputStream) |

#### Instances

Instances details

Eq MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream Methods (==) :: MemoryOutputStream -> MemoryOutputStream -> Bool Source # (/=) :: MemoryOutputStream -> MemoryOutputStream -> Bool Source #
GObject MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream
ManagedPtrNewtype MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream Methods toManagedPtr :: MemoryOutputStream -> ManagedPtr MemoryOutputStream Source #
TypedObject MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream Methods glibType :: IO GType Source #
HasParentTypes MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream
IsGValue (Maybe MemoryOutputStream) Source # | Convert `MemoryOutputStream` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gio.Objects.MemoryOutputStream Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe MemoryOutputStream -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe MemoryOutputStream) Source #
type ParentTypes MemoryOutputStream Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream type ParentTypes MemoryOutputStream = '[OutputStream, Object, PollableOutputStream, Seekable]

class (GObject o, IsDescendantOf MemoryOutputStream o) => IsMemoryOutputStream o Source #

Type class for types which can be safely cast to `MemoryOutputStream`, for instance with `toMemoryOutputStream`.

#### Instances

Instances details

(GObject o, IsDescendantOf MemoryOutputStream o) => IsMemoryOutputStream o Source # |
Instance details Defined in GI.Gio.Objects.MemoryOutputStream

toMemoryOutputStream :: (MonadIO m, IsMemoryOutputStream o) => o -> m MemoryOutputStream Source #

Cast to `MemoryOutputStream`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

bindProperty, bindPropertyFull, canPoll, canSeek, canTruncate, clearPending, close, closeAsync, closeFinish, createSource, flush, flushAsync, flushFinish, forceFloating, freezeNotify, getv, hasPending, isClosed, isClosing, isFloating, isWritable, notify, notifyByPspec, ref, refSink, runDispose, seek, splice, spliceAsync, spliceFinish, stealAsBytes, stealData, stealQdata, tell, thawNotify, truncate, unref, watchClosure, write, writeAll, writeAllAsync, writeAllFinish, writeAsync, writeBytes, writeBytesAsync, writeBytesFinish, writeFinish, writeNonblocking, writev, writevAll, writevAllAsync, writevAllFinish, writevAsync, writevFinish, writevNonblocking.

#### Getters

getData, getDataSize, getProperty, getQdata, getSize.

#### Setters

setData, setDataFull, setPending, setProperty.

## getData

memoryOutputStreamGetData Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) |
=> a | `ostream`: a `MemoryOutputStream`
-> m (Ptr ()) | Returns: pointer to the stream's data, or `Nothing` if the data has been stolen

Gets any loaded data from the `ostream`.

Note that the returned pointer may become invalid on the next write or truncate operation on the stream.

## getDataSize

memoryOutputStreamGetDataSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) |
=> a | `ostream`: a `MemoryOutputStream`
-> m Word64 | Returns: the number of bytes written to the stream

Returns the number of bytes from the start up to including the last byte written in the stream that has not been truncated away.

Since: 2.18

## getSize

memoryOutputStreamGetSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) |
=> a | `ostream`: a `MemoryOutputStream`
-> m Word64 | Returns: the number of bytes allocated for the data buffer

Gets the size of the currently allocated data area (available from `memoryOutputStreamGetData`).

You probably don't want to use this function on resizable streams. See `memoryOutputStreamGetDataSize` instead. For resizable streams the size returned by this function is an implementation detail and may be change at any time in response to operations on the stream.

If the stream is fixed-sized (ie: no realloc was passed to `g_memory_output_stream_new()`) then this is the maximum size of the stream and further writes will return `IOErrorEnumNoSpace`.

In any case, if you want the number of bytes currently written to the stream, use `memoryOutputStreamGetDataSize`.

## newResizable

memoryOutputStreamNewResizable :: (HasCallStack, MonadIO m) => m MemoryOutputStream Source #

Creates a new `MemoryOutputStream`, using `realloc` and `free` for memory allocation.

Since: 2.36

## stealAsBytes

memoryOutputStreamStealAsBytes Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) |
=> a | `ostream`: a `MemoryOutputStream`
-> m Bytes | Returns: the stream's data

Returns data from the `ostream` as a `Bytes`. `ostream` must be closed before calling this function.

Since: 2.34

## stealData

memoryOutputStreamStealData Source #

Arguments

:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) |
=> a | `ostream`: a `MemoryOutputStream`
-> m (Ptr ()) | Returns: the stream's data, or `Nothing` if it has previously been stolen

Gets any loaded data from the `ostream`. Ownership of the data is transferred to the caller; when no longer needed it must be freed using the free function set in `ostream`'s `MemoryOutputStream`:`destroy-function` property.

`ostream` must be closed before calling this function.

Since: 2.26

# Properties

## data

Pointer to buffer where data will be written.

Since: 2.24

constructMemoryOutputStreamData :: (IsMemoryOutputStream o, MonadIO m) => Ptr () -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`data`” property. This is rarely needed directly, but it is used by `new`.

getMemoryOutputStreamData :: (MonadIO m, IsMemoryOutputStream o) => o -> m (Ptr ()) Source #

Get the value of the “`data`” property. When overloading is enabled, this is equivalent to

    get memoryOutputStream #data

## dataSize

Size of data written to the buffer.

Since: 2.24

getMemoryOutputStreamDataSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #

Get the value of the “`data-size`” property. When overloading is enabled, this is equivalent to

    get memoryOutputStream #dataSize

## size

Current size of the data buffer.

Since: 2.24

constructMemoryOutputStreamSize :: (IsMemoryOutputStream o, MonadIO m) => CULong -> m (GValueConstruct o) Source #

Construct a `GValueConstruct` with valid value for the “`size`” property. This is rarely needed directly, but it is used by `new`.

getMemoryOutputStreamSize :: (MonadIO m, IsMemoryOutputStream o) => o -> m CULong Source #

Get the value of the “`size`” property. When overloading is enabled, this is equivalent to

    get memoryOutputStream #size