Skip to content

Back Blob with [UInt8] instead of NSData? #188

Closed
@lukescott

Description

@lukescott

Can Blob be backed by [UInt8] instead of NSData? It would be one less Foundation dependency. Something like:

public struct Blob {
    let data: [UInt8]

    public init(data: [UInt8]) {
        self.data = data
    }

    public init(bytes: UnsafePointer<Void>, length: Int) {
        data = [UInt8](UnsafeBufferPointer<UInt8>(
            start: UnsafePointer<UInt8>(bytes),
            count: length
        ))
    }
}
// deprecate (backwards compatibility)
extension Blob {
    public var bytes: UnsafePointer<Void> {
        return UnsafePointer<Void>(data)
    }

    public var length: Int {
        return data.count
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions