Skip to content

Commit

Permalink
Cleanup EntityType (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Apr 10, 2024
1 parent e3865ba commit 844d1a1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 164 deletions.
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.

0 comments on commit 844d1a1

Please sign in to comment.