Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
A simple refcounted data type representing an immutable sequence of zero or more bytes from an unspecified origin.
The purpose of a #GBytes is to keep the memory region that it holds alive for as long as anyone holds a reference to the bytes. When the last reference count is dropped, the memory is released. Multiple unrelated callers can use byte data in the #GBytes without coordinating their activities, resting assured that the byte data will not change or move while they hold a reference.
A #GBytes can come from many different origins that may have different procedures for freeing the memory region. Examples are memory from g_malloc(), from memory slices, from a #GMappedFile or memory from other allocators.
GHashTable. Use g_bytes_equal() and g_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full(). GTree by passing the g_bytes_compare() function to g_tree_new().
The data pointed to by this bytes must not be modified. For a mutable array of bytes see #GByteArray. Use g_bytes_unref_to_array() to create a mutable array for a GBytes from a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
- newtype Bytes = Bytes (ForeignPtr Bytes)
- noBytes :: Maybe Bytes
- data BytesCompareMethodInfo
- bytesCompare :: MonadIO m => Bytes -> Bytes -> m Int32
- data BytesEqualMethodInfo
- bytesEqual :: MonadIO m => Bytes -> Bytes -> m Bool
- data BytesGetDataMethodInfo
- bytesGetData :: MonadIO m => Bytes -> m ByteString
- data BytesGetSizeMethodInfo
- bytesGetSize :: MonadIO m => Bytes -> m Word64
- data BytesHashMethodInfo
- bytesHash :: MonadIO m => Bytes -> m Word32
- bytesNew :: MonadIO m => Maybe ByteString -> m Bytes
- data BytesNewFromBytesMethodInfo
- bytesNewFromBytes :: MonadIO m => Bytes -> Word64 -> Word64 -> m Bytes
- bytesNewTake :: MonadIO m => Maybe ByteString -> m Bytes
- data BytesRefMethodInfo
- bytesRef :: MonadIO m => Bytes -> m Bytes
- data BytesUnrefMethodInfo
- bytesUnref :: MonadIO m => Bytes -> m ()
- data BytesUnrefToArrayMethodInfo
- bytesUnrefToArray :: MonadIO m => Bytes -> m ByteString
- data BytesUnrefToDataMethodInfo
- bytesUnrefToData :: MonadIO m => Bytes -> Word64 -> m ()
Exported types
Methods
bytesCompare
bytesEqual
bytesGetData
data BytesGetDataMethodInfo Source
((~) (TYPE Lifted) signature (m ByteString), MonadIO m) => MethodInfo (TYPE Lifted) BytesGetDataMethodInfo Bytes signature Source | |
bytesGetData :: MonadIO m => Bytes -> m ByteString Source
bytesGetSize
data BytesGetSizeMethodInfo Source
((~) (TYPE Lifted) signature (m Word64), MonadIO m) => MethodInfo (TYPE Lifted) BytesGetSizeMethodInfo Bytes signature Source | |
bytesGetSize :: MonadIO m => Bytes -> m Word64 Source
bytesHash
data BytesHashMethodInfo Source
((~) (TYPE Lifted) signature (m Word32), MonadIO m) => MethodInfo (TYPE Lifted) BytesHashMethodInfo Bytes signature Source | |
bytesNew
bytesNewFromBytes
bytesNewTake
bytesNewTake :: MonadIO m => Maybe ByteString -> m Bytes Source
bytesRef
data BytesRefMethodInfo Source
((~) (TYPE Lifted) signature (m Bytes), MonadIO m) => MethodInfo (TYPE Lifted) BytesRefMethodInfo Bytes signature Source | |
bytesUnref
data BytesUnrefMethodInfo Source
((~) (TYPE Lifted) signature (m ()), MonadIO m) => MethodInfo (TYPE Lifted) BytesUnrefMethodInfo Bytes signature Source | |
bytesUnref :: MonadIO m => Bytes -> m () Source
bytesUnrefToArray
data BytesUnrefToArrayMethodInfo Source
((~) (TYPE Lifted) signature (m ByteString), MonadIO m) => MethodInfo (TYPE Lifted) BytesUnrefToArrayMethodInfo Bytes signature Source | |
bytesUnrefToArray :: MonadIO m => Bytes -> m ByteString Source
bytesUnrefToData
data BytesUnrefToDataMethodInfo Source
((~) (TYPE Lifted) signature (Word64 -> m ()), MonadIO m) => MethodInfo (TYPE Lifted) BytesUnrefToDataMethodInfo Bytes signature Source | |
bytesUnrefToData :: MonadIO m => Bytes -> Word64 -> m () Source