byteslice-0.1.2.0: Slicing managed and unmanaged memory

Safe HaskellNone
LanguageHaskell2010

Data.Bytes

Contents

Synopsis

Types

data Bytes Source #

A slice of a ByteArray.

Instances
IsList Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Associated Types

type Item Bytes :: Type #

Eq Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Methods

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

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

Ord Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Methods

compare :: Bytes -> Bytes -> Ordering #

(<) :: Bytes -> Bytes -> Bool #

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

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

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

max :: Bytes -> Bytes -> Bytes #

min :: Bytes -> Bytes -> Bytes #

Show Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Methods

showsPrec :: Int -> Bytes -> ShowS #

show :: Bytes -> String #

showList :: [Bytes] -> ShowS #

Semigroup Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Methods

(<>) :: Bytes -> Bytes -> Bytes #

sconcat :: NonEmpty Bytes -> Bytes #

stimes :: Integral b => b -> Bytes -> Bytes #

type Item Bytes Source # 
Instance details

Defined in Data.Bytes.Types

Properties

null :: Bytes -> Bool Source #

Is the byte sequence empty?

length :: Bytes -> Int Source #

The length of a slice of bytes.

Filtering

takeWhile :: (Word8 -> Bool) -> Bytes -> Bytes Source #

Take bytes while the predicate is true.

dropWhile :: (Word8 -> Bool) -> Bytes -> Bytes Source #

Drop bytes while the predicate is true.

Unsafe Slicing

unsafeTake :: Int -> Bytes -> Bytes Source #

Take the first n bytes from the argument. Precondition: n ≤ len

unsafeDrop :: Int -> Bytes -> Bytes Source #

Drop the first n bytes from the argument. Precondition: n ≤ len

Conversion

toByteArray :: Bytes -> ByteArray Source #

Convert the sliced Bytes to an unsliced ByteArray. This reuses the array backing the sliced Bytes if the slicing metadata implies that all of the bytes are used. Otherwise, it makes a copy.

toByteArrayClone :: Bytes -> ByteArray Source #

Variant of toByteArray that unconditionally makes a copy of the array backing the sliced Bytes even if the original array could be reused. Prefer toByteArray.

fromAsciiString :: String -> Bytes Source #

Convert a String consisting of only characters in the ASCII block.

fromByteArray :: ByteArray -> Bytes Source #

Create a slice of Bytes that spans the entire argument array.