Skip to content
Snippets Groups Projects
Select Git revision
  • b32eed3962e8f82dacc387a9b8efae461eb8177b
  • 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

E2EAddPartnerCallback.swift

Blame
  • ConnectionMaker.swift 1.10 KiB
    import Bindings
    
    public struct ConnectionMaker {
      public var connect: (Bool, Data, Data) throws -> Connection
    
      public func callAsFunction(
        withAuthentication: Bool,
        recipientContact: Data,
        myIdentity: Data
      ) throws -> Connection {
        try connect(withAuthentication, recipientContact, myIdentity)
      }
    }
    
    extension ConnectionMaker {
      public static func live(bindingsClient: BindingsClient) -> ConnectionMaker {
        ConnectionMaker { withAuthentication, recipientContact, myIdentity in
          if withAuthentication {
            return Connection.live(
              bindingsConnection: try bindingsClient.connect(
                recipientContact,
                myIdentity: myIdentity
              )
            )
          } else {
            return Connection.live(
              bindingsAuthenticatedConnection: try bindingsClient.connect(
                withAuthentication: recipientContact,
                myIdentity: myIdentity
              )
            )
          }
        }
      }
    }
    
    #if DEBUG
    extension ConnectionMaker {
      public static let failing = ConnectionMaker { _, _, _ in
        struct NotImplemented: Error {}
        throw NotImplemented()
      }
    }
    #endif