summaryrefslogtreecommitdiffhomepage
path: root/ios/PacketTunnelCore/IPC/TunnelProviderReply.swift
blob: faa9d6d60c3e296418905170b4b993c7d685afaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
//  TunnelProviderReply.swift
//  PacketTunnelCore
//
//  Created by pronebird on 20/10/2022.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation

/// Container type for tunnel provider reply.
public struct TunnelProviderReply<T: Codable>: Codable {
    public var value: T

    public init(_ value: T) {
        self.value = value
    }

    public init(messageData: Data) throws {
        self = try JSONDecoder().decode(Self.self, from: messageData)
    }

    public func encode() throws -> Data {
        try JSONEncoder().encode(self)
    }
}