Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 961 Bytes

README.md

File metadata and controls

44 lines (33 loc) · 961 Bytes

Bytes

Bytes is a [UInt8]-backed struct meant to represent small sequences of bytes and can be used for things like binary headers, identifiers, random bytes, etc. The string representation for Bytes is a hex encoded String.

Usage

struct Key: Hashable {
    let name: String
    let bytes: Bytes

    init(name: String) {
        self.bytes = Bytes.random()
        self.name = name
    }

    init(name: String, bytes: Bytes) {
        self.bytes = bytes
        self.name = name
    }
}

let important = Key(name: "Important", bytes: Bytes(rawValue: [101, 42, 101]))
let random = Key(name: "Random")

// ...

Installation

Swift Package Manager

To use Bytes with the Swift Package Manager, add a dependency to your Package.swift file:

let package = Package(
   dependencies: [
       .package(
           url: "https://github.com/shareup/bytes-apple.git",
           from: "3.1.0"
       )
   ]
)