LowercaseDigits
Base16.LowercaseDigits.swift:6enum LowercaseDigits
enum LowercaseDigits
import Base16
enum Base16
A namespace for base-16 utilities.
static func decode<ASCII>(_ ascii: ASCII, into bytes: UnsafeMutableRawBufferPointer) -> Void? where ASCII : Sequence, ASCII.Element == UInt8
Decodes an ASCII-encoded base-16 string into a pre-allocated buffer, returning nil
if the input did not yield enough digits to fill the buffer completely.
static func decode<BigEndian>(_ ascii: some Sequence<UInt8>, loading _: BigEndian.Type = BigEndian.self) -> BigEndian?
Decodes an ASCII-encoded base-16 string to some (usually trivial) type. This is essentially the same as loading values from raw memory, so this method should only be used to load trivial types.
static func decode<ASCII, Bytes>(_ ascii: ASCII, to _: Bytes.Type = Bytes.self) -> Bytes where ASCII : Sequence, Bytes : RangeReplaceableCollection, ASCII.Element == UInt8, Bytes.Element == UInt8
Decodes an ASCII-encoded base-16 string to some RangeReplaceableCollection
type. The order of the decoded bytes in the output matches the order of the (pairs of) hexadecimal digits in the input.
static func decode<Bytes>(_ ascii: some StringProtocol, to _: Bytes.Type = Bytes.self) -> Bytes where Bytes : RangeReplaceableCollection, Bytes.Element == UInt8
Decodes some String
-like type containing an ASCII-encoded base-16 string to some RangeReplaceableCollection
type. The order of the decoded bytes in the output matches the order of the (pairs of) hexadecimal digits in the input string.
static func encode<Digits>(_ bytes: some Sequence<UInt8>, with _: Digits.Type) -> String where Digits : BaseDigits
Encodes a sequence of bytes to a base-16 string with the specified lettercasing.
static func encode<BigEndian, Digits>(storing words: BigEndian, into ascii: UnsafeMutableRawBufferPointer, with _: Digits.Type) where Digits : BaseDigits
Encodes a sequence of bytes into a pre-allocated buffer as a base-16 string with the specified lettercasing.
static func encode<BigEndian, Digits>(storing words: BigEndian, with _: Digits.Type) -> String where Digits : BaseDigits
Encodes the raw bytes of the given value to a base-16 string with the specified lettercasing. The bytes with the lowest addresses appear first in the encoded output.
enum UppercaseDigits
struct Values<ASCII> where ASCII : Sequence, ASCII.Element == UInt8
An abstraction over text input, which discards characters that are not valid base-16 digits.
protocol BaseDigits
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
static subscript(remainder: UInt8) -> UInt8 { get }
static subscript(remainder: UInt8, as _: Character.Type = Character.self) -> Character { get }
Gets the ASCII value for the given remainder as a Character
.
static subscript(remainder: UInt8, as _: Unicode.Scalar.Type = Unicode.Scalar.self) -> Unicode.Scalar { get }
Gets the ASCII value for the given remainder as a Unicode.Scalar
.