Bytes.Comparable

Comparable Bytes

-- TODO: Because we rely on the sorting of the hex string, -- it is super important to check that we only use -- lower case letters, but no uppercase.

type Bytes a

A custom Bytes type that is comparable with ==.

Useful as otherwise, the original Bytes type from elm/bytes package cannot be used to compare for equality with ==. The phantom type parameter a indicates what type of Bytes are stored.

type Any

A catch-all phantom type for bytes.

Convert any type of bytes to Bytes Any.

concat : Bytes a -> Bytes b -> Bytes c

Concatenate two bytes sequences.

chunksOf : Int -> Bytes a -> List (Bytes a)

Break a Bytestring into a list of chunks. Chunks are of the given width, except the last chunk which is only at most the given width.

width : Bytes a -> Int

Length in bytes.

isEmpty : Bytes a -> Bool

Check if this is empy.

Create an empty Bytes object.

fromBytes : Bytes -> Bytes a

Create a [Bytes] object from an elm/bytes [Bytes.Bytes].

fromHex : String -> Maybe (Bytes a)

Create a [Bytes] object from a hex-encoded string.

fromHexUnchecked : String -> Bytes a

Same as [fromHex] except it does not check that the hex-encoded string is well formed. It is your responsability.

fromText : String -> Bytes a

Create a [Bytes] with some text encoded as UTF8.

fromU8 : List Int -> Bytes a

Create a [Bytes] object from individual U8 integers.

toBytes : Bytes a -> Bytes

Convert [Bytes] into elm/bytes [Bytes.Bytes].

toHex : Bytes a -> String

Convert [Bytes] into a hex-encoded String.

toText : Bytes a -> Maybe String

Convert [Bytes] into a UTF8 String.

toCbor : Bytes a -> Encoder

Cbor encoder.

toU8 : Bytes a -> List Int

Convert a given [Bytes] into a list of U8 integers.

jsonEncode : Bytes a -> Value

JSON encoder for Bytes.

jsonDecoder : Decoder (Bytes a)

JSON decoder for Bytes.

Compute the Blake2b-224 hash (28 bytes) of the given bytes.

Compute the Blake2b-256 hash (32 bytes) of the given bytes.

Compute the Blake2b-512 hash (64 bytes) of the given bytes.

dummy : Int -> String -> Bytes a

Helper function to make up some bytes of a given length, starting by the given text when decoded as text.

dummyWithPrefix : Int -> Bytes a -> Bytes b

Helper function to make up some bytes of a given length, starting with the provided bytes.

pretty : Bytes a -> String

Helper function that convert bytes to either Text if it looks like text, or its Hex representation otherwise.