Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
MemoryOutputStream
is a class for using arbitrary
memory chunks as output for GIO streaming output operations.
As of GLib 2.34, MemoryOutputStream
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.
Instances
Eq MemoryOutputStream Source # | |
Defined in GI.Gio.Objects.MemoryOutputStream (==) :: MemoryOutputStream -> MemoryOutputStream -> Bool # (/=) :: MemoryOutputStream -> MemoryOutputStream -> Bool # | |
IsGValue MemoryOutputStream Source # | Convert |
Defined in GI.Gio.Objects.MemoryOutputStream toGValue :: MemoryOutputStream -> IO GValue # fromGValue :: GValue -> IO MemoryOutputStream # | |
ManagedPtrNewtype MemoryOutputStream Source # | |
TypedObject MemoryOutputStream Source # | |
Defined in GI.Gio.Objects.MemoryOutputStream | |
GObject MemoryOutputStream Source # | |
Defined in GI.Gio.Objects.MemoryOutputStream | |
HasParentTypes MemoryOutputStream Source # | |
Defined in GI.Gio.Objects.MemoryOutputStream | |
type ParentTypes MemoryOutputStream Source # | |
Defined in GI.Gio.Objects.MemoryOutputStream |
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
(GObject o, IsDescendantOf MemoryOutputStream o) => IsMemoryOutputStream o Source # | |
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
Overloaded methods
getData
memoryOutputStreamGetData Source #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> m (Ptr ()) | Returns: pointer to the stream's data, or |
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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> 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 #
:: (HasCallStack, MonadIO m, IsMemoryOutputStream a) | |
=> a |
|
-> m (Ptr ()) | Returns: the stream's data, or |
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