-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from metaplex-foundation/fix/expose-encoders
Expose encoders
- Loading branch information
Showing
2 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import Foundation | ||
|
||
struct BorshDecoder { | ||
func decode<T>(_ type: T.Type, from data: Data) throws -> T where T: BorshDeserializable { | ||
var reader = BinaryReader(bytes: [UInt8](data)) | ||
return try T.init(from: &reader) | ||
} | ||
public struct BorshDecoder { | ||
public func decode<T>(_ type: T.Type, from data: Data) throws -> T where T: BorshDeserializable { | ||
var reader = BinaryReader(bytes: [UInt8](data)) | ||
return try T.init(from: &reader) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import Foundation | ||
|
||
struct BorshEncoder { | ||
func encode<T>(_ value: T) throws -> Data where T: BorshSerializable { | ||
var writer = Data() | ||
try value.serialize(to: &writer) | ||
return writer | ||
} | ||
public struct BorshEncoder { | ||
public func encode<T>(_ value: T) throws -> Data where T: BorshSerializable { | ||
var writer = Data() | ||
try value.serialize(to: &writer) | ||
return writer | ||
} | ||
} |