Skip to content
Snippets Groups Projects
Select Git revision
  • 569c862eab1601dd674efc96c56525184ff83320
  • main default protected
  • development
  • integration
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
11 results

LoadCMix.swift

Blame
  • LoadCMix.swift 880 B
    import Bindings
    import XCTestDynamicOverlay
    
    public struct LoadCMix {
      public var run: (String, Data, Data) throws -> CMix
    
      public func callAsFunction(
        storageDir: String,
        password: Data,
        cMixParamsJSON: Data = GetCMixParams.liveDefault()
      ) throws -> CMix {
        try run(storageDir, password, cMixParamsJSON)
      }
    }
    
    extension LoadCMix {
      public static let live = LoadCMix { storageDir, password, cMixParamsJSON in
        var error: NSError?
        let bindingsCMix = BindingsLoadCmix(storageDir, password, cMixParamsJSON, &error)
        if let error = error {
          throw error
        }
        guard let bindingsCMix = bindingsCMix else {
          fatalError("BindingsLoadCMix returned `nil` without providing error")
        }
        return CMix.live(bindingsCMix)
      }
    }
    
    extension LoadCMix {
      public static let unimplemented = LoadCMix(
        run: XCTUnimplemented("\(Self.self)")
      )
    }