Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup EntityType #473

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Sources/VergeSwiftUI/Info.plist

This file was deleted.

19 changes: 0 additions & 19 deletions Sources/VergeSwiftUI/VergeSwiftUI.h

This file was deleted.

48 changes: 5 additions & 43 deletions Sources/VergeTypedIdentifier/EntityType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,71 +19,33 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import Foundation

public struct AnyEntityIdentifier: Hashable, Sendable {

public typealias StringLiteralType = String

public let value: PrimitiveIdentifier
public init(_ value: PrimitiveIdentifier) {
self.value = value
}

}

public struct EntityIdentifier<Entity: EntityType> : Hashable, CustomStringConvertible, Sendable {

public static func == (lhs: Self, rhs: Self) -> Bool {
lhs.raw == rhs.raw
}

public func hash(into hasher: inout Hasher) {
raw.hash(into: &hasher)
}

public let any: AnyEntityIdentifier

public let raw: Entity.EntityIDRawType

public init(_ raw: Entity.EntityIDRawType) {
public init(_ raw: consuming Entity.EntityIDRawType) {
self.raw = raw
self.any = .init(raw._primitiveIdentifier)
}

@_spi(ForORM)
public init(_ anyIdentifier: AnyEntityIdentifier) {
self.any = anyIdentifier
self.raw = Entity.EntityIDRawType._restore(from: anyIdentifier.value)!
}


public var description: String {
"<\(String(reflecting: Entity.self))>(\(raw))"
}
}

/// A protocol describes object is an Entity.
///
/// EntityType has VergeTypedIdentifiable.
/// You might use IdentifiableEntityType instead, if you create SwiftUI app.
public protocol EntityType: Equatable, Sendable {

associatedtype EntityIDRawType: _PrimitiveIdentifierConvertible
associatedtype EntityIDRawType: Hashable, Sendable

var entityID: EntityID { get }

typealias EntityID = EntityIdentifier<Self>
}

public struct EntityTableIdentifier: Hashable {

public let name: String

public init(_ rawName: String) {
self.name = rawName
}

public init<T>(_ type: T.Type) {
self.name = _typeName(T.self)
}
}
80 changes: 0 additions & 80 deletions Sources/VergeTypedIdentifier/PrimitiveIdentifier.swift

This file was deleted.

Loading