generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some drafts around user info support
- Loading branch information
Showing
5 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,24 +14,26 @@ 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"]), | ||
.library(name: "XCTByteCoding", targets: ["XCTByteCoding"]), | ||
.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: "[email protected]: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") | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ByteCodingUserInfoAnchor> | ||
|
||
/* | ||
TODO: custom type? | ||
public struct ByteCodingUserInfo: SharedRepository { | ||
public typealias Anchor = ByteCodingUserInfoAnchor | ||
|
||
|
||
fileprivate init() {} | ||
|
||
|
||
public func get<Source>(_ source: Source.Type) -> Source.Value? where Source : SpeziFoundation.KnowledgeSource, ByteCodingUserInfoAnchor == Source.Anchor { | ||
<#code#> | ||
} | ||
|
||
public mutating func set<Source>(_ source: Source.Type, value newValue: Source.Value?) where Source : SpeziFoundation.KnowledgeSource, ByteCodingUserInfoAnchor == Source.Anchor { | ||
<#code#> | ||
} | ||
|
||
public func collect<Value>(allOf type: Value.Type) -> [Value] { | ||
<#code#> | ||
} | ||
} | ||
|
||
|
||
extension ByteCodingUserInfo { | ||
@TaskLocal public var userInfo = ByteCodingUserInfo() | ||
}*/ |
12 changes: 12 additions & 0 deletions
12
Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfoKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ByteCodingUserInfoAnchor> {} |
31 changes: 31 additions & 0 deletions
31
Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
} |