memory-0.15.0: memory and related abstraction stuff
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilitystable
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Data.ByteArray

Description

Simple and efficient byte array types

This module should be imported qualified.

Synopsis

ByteArray Classes

ByteArray built-in types

data Bytes Source #

Simplest Byte Array

Instances

Instances details
Eq Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Methods

(==) :: Bytes -> Bytes -> Bool Source #

(/=) :: Bytes -> Bytes -> Bool Source #

Ord Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Show Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Semigroup Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Monoid Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

NormalForm Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Methods

toNormalForm :: Bytes -> () Source #

NFData Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Methods

rnf :: Bytes -> () Source #

ByteArray Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Methods

allocRet :: Int -> (Ptr p -> IO a) -> IO (a, Bytes) Source #

ByteArrayAccess Bytes Source # 
Instance details

Defined in Data.ByteArray.Bytes

Methods

length :: Bytes -> Int Source #

withByteArray :: Bytes -> (Ptr p -> IO a) -> IO a Source #

copyByteArrayToPtr :: Bytes -> Ptr p -> IO () 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

Instances details
Eq ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Ord ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Show ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

IsString ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Semigroup ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Monoid ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

NormalForm ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

NFData ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Methods

rnf :: ScrubbedBytes -> () Source #

ByteArray ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

Methods

allocRet :: Int -> (Ptr p -> IO a) -> IO (a, ScrubbedBytes) Source #

ByteArrayAccess ScrubbedBytes Source # 
Instance details

Defined in Data.ByteArray.ScrubbedBytes

data MemView Source #

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)

Constructors

MemView !(Ptr Word8) !Int 

Instances

Instances details
Eq MemView Source # 
Instance details

Defined in Data.ByteArray.MemView

Show MemView Source # 
Instance details

Defined in Data.ByteArray.MemView

ByteArrayAccess MemView Source # 
Instance details

Defined in Data.ByteArray.MemView

data View bytes Source #

a view on a given bytes

Equality test in constant time

Instances

Instances details
ByteArrayAccess bytes => Eq (View bytes) Source # 
Instance details

Defined in Data.ByteArray.View

Methods

(==) :: View bytes -> View bytes -> Bool Source #

(/=) :: View bytes -> View bytes -> Bool Source #

ByteArrayAccess bytes => Ord (View bytes) Source # 
Instance details

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 #

max :: View bytes -> View bytes -> View bytes Source #

min :: View bytes -> View bytes -> View bytes Source #

ByteArrayAccess bytes => Show (View bytes) Source # 
Instance details

Defined in Data.ByteArray.View

Methods

showsPrec :: Int -> View bytes -> ShowS Source #

show :: View bytes -> String Source #

showList :: [View bytes] -> ShowS Source #

ByteArrayAccess bytes => ByteArrayAccess (View bytes) Source # 
Instance details

Defined in Data.ByteArray.View

Methods

length :: View bytes -> Int Source #

withByteArray :: View bytes -> (Ptr p -> IO a) -> IO a Source #

copyByteArrayToPtr :: View bytes -> Ptr p -> IO () Source #

view 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

takeView Source #

Arguments

:: ByteArrayAccess bytes 
=> bytes

byte aray

-> Int

size of the view

-> View bytes 

create a view from the given bytearray

dropView Source #

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