Skip to content

Commit

Permalink
Some drafts around user info support
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jun 10, 2024
1 parent 5e203c9 commit d827e83
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift
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?

Check failure on line 12 in Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (docs, hidden?) (todo)
public struct ByteCodingUserInfoAnchor: RepositoryAnchor {}


public typealias ByteCodingUserInfo = ValueRepository<ByteCodingUserInfoAnchor>

Check failure on line 16 in Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Missing Docs Violation: public declarations should be documented (missing_docs)

/*
TODO: custom type?

Check failure on line 19 in Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfo.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (custom type?) (todo)
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 Sources/ByteCoding/ByteCodingUserInfo/ByteCodingUserInfoKey.swift
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> {}
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

Check failure on line 10 in Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Sorted Imports Violation: Imports should be sorted (sorted_imports)


private struct PrimitiveByteCodableEndiannessKey: ByteCodingUserInfoKey, DefaultProvidingKnowledgeSource {
typealias Value = Endianness

static let defaultValue: Endianness = .little
}


extension ByteCodingUserInfo {
// TODO: @TaskLocal public var byteCodingUserInfo: ByteCodingUserInfo

Check failure on line 21 in Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Todo Violation: TODOs should be resolved (@TaskLocal public var byteCodi...) (todo)

public var defaultEndianness: Endianness {

Check failure on line 23 in Sources/ByteCoding/ByteCodingUserInfo/PrimitiveByteCodableEndiannessKey.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Missing Docs Violation: public declarations should be documented (missing_docs)
get {
self[PrimitiveByteCodableEndiannessKey.self]
}
set {
self[PrimitiveByteCodableEndiannessKey.self] = newValue
}
}
}

0 comments on commit d827e83

Please sign in to comment.