You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
LeStorage/LeStorage/Storable.swift

26 lines
551 B

//
// Storable.swift
// LeStorage
//
// Created by Laurent Morvillier on 03/02/2024.
//
import Foundation
public protocol Storable: Codable, Identifiable where ID : StringProtocol {
static func resourceName() -> String
func deleteDependencies() throws
}
extension Storable {
public func findById<T : Storable>(_ id: String) -> T? {
return Store.main.findById(id)
}
static func fileName() -> String {
return self.resourceName() + ".json"
}
var stringId: String { return String(self.id) }
}