License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | stable |
Portability | Good |
Safe Haskell | None |
Language | Haskell2010 |
Data.ByteArray
Description
Simple and efficient byte array types
This module should be imported qualified.
Synopsis
- module Data.ByteArray.Types
- data Bytes
- data ScrubbedBytes
- data MemView = MemView !(Ptr Word8) !Int
- data View bytes
- view :: ByteArrayAccess bytes => bytes -> Int -> Int -> View bytes
- takeView :: ByteArrayAccess bytes => bytes -> Int -> View bytes
- dropView :: ByteArrayAccess bytes => bytes -> Int -> View bytes
- module Data.ByteArray.Methods
ByteArray Classes
module Data.ByteArray.Types
ByteArray built-in types
Simplest Byte Array
Instances
Eq Bytes Source # | |
Ord Bytes Source # | |
Defined in Data.ByteArray.Bytes | |
Show Bytes Source # | |
Semigroup Bytes Source # | |
Monoid Bytes Source # | |
NormalForm Bytes Source # | |
Defined in Data.ByteArray.Bytes Methods toNormalForm :: Bytes -> () Source # | |
NFData Bytes Source # | |
Defined in Data.ByteArray.Bytes | |
ByteArray Bytes Source # | |
ByteArrayAccess Bytes Source # | |
data ScrubbedBytes Source #
ScrubbedBytes is a memory chunk which have the properties of:
- Being scrubbed after its goes out of scope.
- A Show instance that doesn't actually show any content
- A Eq instance that is constant time
Instances
A simple abstraction to a piece of memory.
Do beware that garbage collection related to piece of memory could be triggered before this is used.
Only use with the appropriate handler has been used (e.g. withForeignPtr on ForeignPtr)
a view on a given bytes
Equality test in constant time
Instances
ByteArrayAccess bytes => Eq (View bytes) Source # | |
ByteArrayAccess bytes => Ord (View bytes) Source # | |
Defined in Data.ByteArray.View Methods compare :: View bytes -> View bytes -> Ordering Source # (<) :: View bytes -> View bytes -> Bool Source # (<=) :: View bytes -> View bytes -> Bool Source # (>) :: View bytes -> View bytes -> Bool Source # (>=) :: View bytes -> View bytes -> Bool Source # | |
ByteArrayAccess bytes => Show (View bytes) Source # | |
ByteArrayAccess bytes => ByteArrayAccess (View bytes) Source # | |
Arguments
:: ByteArrayAccess bytes | |
=> bytes | the byte array we put a view on |
-> Int | the offset to start the byte array on |
-> Int | the size of the view |
-> View bytes |
create a view on a given bytearray
This function update the offset and the size in order to guarantee:
- offset >= 0
- size >= 0
- offset < length
- size =< length - offset
Arguments
:: ByteArrayAccess bytes | |
=> bytes | byte aray |
-> Int | size of the view |
-> View bytes |
create a view from the given bytearray
Arguments
:: ByteArrayAccess bytes | |
=> bytes | byte array |
-> Int | the number of bytes do dropped before creating the view |
-> View bytes |
create a view from the given byte array starting after having dropped the fist n bytes
ByteArray methods
module Data.ByteArray.Methods