AutoCat/AutoCatCore/Models/Protocols/DtoConvertible.swift

34 lines
560 B
Swift

//
// DtoConvertible.swift
// AutoCatCore
//
// Created by Selim Mustafaev on 13.06.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import Foundation
public protocol DtoConvertible {
associatedtype Dto
var dto: Dto { get }
var shallowDto: Dto { get }
init(dto: Dto)
init?(dto: Dto?)
}
extension DtoConvertible {
public var shallowDto: Dto { dto }
public init?(dto: Dto?) {
guard let dto else {
return nil
}
self.init(dto: dto)
}
}