-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
byte[] is the standard type used for IO operations within dotnet ecosystem. Since `bytes` type would normally be used in IO context, representings `bytes` as `List<byte>` was not a good choice. Passing any `byte[]` IO data between C# and Rust would involve an additional copy from `byte[]` to `List<byte>`. Using `byte[]` directly in uniffi bindings removes the need for this extra copy. List of IO classes using `byte[]`: FileStream, BinaryReader, BinaryWriter, MemoryStream, Socket, NetworkStream, GZipStream, DeflareStream, Aes, RSA, SHA256, WebClient, HttpClient.
- Loading branch information
Showing
12 changed files
with
26 additions
and
87 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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{#/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */#} | ||
|
||
class {{ ffi_converter_name }}: FfiConverterRustBuffer<{{ type_name }}> { | ||
public static {{ ffi_converter_name }} INSTANCE = new {{ ffi_converter_name }}(); | ||
|
||
public override {{ type_name }} Read(BigEndianStream stream) { | ||
var length = stream.ReadInt(); | ||
return stream.ReadBytes(length); | ||
} | ||
|
||
public override int AllocationSize({{ type_name }} value) { | ||
return 4 + value.Length; | ||
} | ||
|
||
public override void Write({{ type_name }} value, BigEndianStream stream) { | ||
stream.WriteInt(value.Length); | ||
stream.WriteBytes(value); | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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