diff --git a/Package.swift b/Package.swift index ed66ad4..16bdda3 100644 --- a/Package.swift +++ b/Package.swift @@ -14,11 +14,11 @@ import PackageDescription let package = Package( name: "SpeziNetworking", platforms: [ - .iOS(.v16), - .watchOS(.v9), + .iOS(.v17), + .watchOS(.v10), .visionOS(.v1), - .macOS(.v13), - .tvOS(.v16) + .macOS(.v14), + .tvOS(.v17) ], products: [ .library(name: "ByteCoding", targets: ["ByteCoding"]), @@ -26,12 +26,14 @@ let package = Package( .library(name: "SpeziNumerics", targets: ["SpeziNumerics"]) ], dependencies: [ - .package(url: "https://github.com/apple/swift-nio.git", from: "2.59.0") + .package(url: "https://github.com/apple/swift-nio.git", from: "2.59.0"), + .package(url: "git@github.com:StanfordSpezi/SpeziFoundation.git", from: "1.0.4") ], targets: [ .target( name: "ByteCoding", dependencies: [ + .product(name: "SpeziFoundation", package: "SpeziFoundation"), .product(name: "NIO", package: "swift-nio"), .product(name: "NIOFoundationCompat", package: "swift-nio") ] diff --git a/README.md b/README.md index 0af8b60..e6f6989 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ SPDX-License-Identifier: MIT [![DOI](https://zenodo.org/badge/811321013.svg)](https://zenodo.org/doi/10.5281/zenodo.11508061) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordSpezi%2FSpeziNetworking%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StanfordSpezi/SpeziNetworking) [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordSpezi%2FSpeziNetworking%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StanfordSpezi/SpeziNetworking) + A collection of networking-related infrastructure to support Spezi applications. ## Overview diff --git a/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift b/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift new file mode 100644 index 0000000..de2baa4 --- /dev/null +++ b/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift @@ -0,0 +1,43 @@ +// +// This source file is part of the Stanford Spezi open-source project +// +// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import SpeziFoundation + + +// TODO: docs, hidden? +public struct ByteCodingUserInfoAnchor: RepositoryAnchor {} + + +public typealias ByteCodingUserInfo = ValueRepository + +/* + TODO: custom type? +public struct ByteCodingUserInfo: SharedRepository { + public typealias Anchor = ByteCodingUserInfoAnchor + + + fileprivate init() {} + + + public func get(_ source: Source.Type) -> Source.Value? where Source : SpeziFoundation.KnowledgeSource, ByteCodingUserInfoAnchor == Source.Anchor { + <#code#> + } + + public mutating func set(_ source: Source.Type, value newValue: Source.Value?) where Source : SpeziFoundation.KnowledgeSource, ByteCodingUserInfoAnchor == Source.Anchor { + <#code#> + } + + public func collect(allOf type: Value.Type) -> [Value] { + <#code#> + } +} + + +extension ByteCodingUserInfo { + @TaskLocal public var userInfo = ByteCodingUserInfo() +}*/ diff --git a/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfoKey.swift b/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfoKey.swift new file mode 100644 index 0000000..89f0f25 --- /dev/null +++ b/Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfoKey.swift @@ -0,0 +1,12 @@ +// +// This source file is part of the Stanford Spezi open-source project +// +// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import SpeziFoundation + + +public protocol ByteCodingUserInfoKey: KnowledgeSource {} diff --git a/Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift b/Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift new file mode 100644 index 0000000..dc9e0af --- /dev/null +++ b/Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift @@ -0,0 +1,31 @@ +// +// This source file is part of the Stanford Spezi open-source project +// +// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import SpeziFoundation +import NIOCore + + +private struct PrimitiveByteCodableEndiannessKey: ByteCodingUserInfoKey, DefaultProvidingKnowledgeSource { + typealias Value = Endianness + + static let defaultValue: Endianness = .little +} + + +extension ByteCodingUserInfo { + // TODO: @TaskLocal public var byteCodingUserInfo: ByteCodingUserInfo + + public var defaultEndianness: Endianness { + get { + self[PrimitiveByteCodableEndiannessKey.self] + } + set { + self[PrimitiveByteCodableEndiannessKey.self] = newValue + } + } +}