Extensions

  • 2 minutes to read
Warning

As of VoltRpc 3.2.0, these extensions are now built into VoltRpc!

Only use the packages if you are on an older version of VoltRpc and need Vector and/or memory support.

VoltRpc has some first-party extensions for it. These are usually for extending the Type capability of BufferedWriter and BufferedReader as well as providing TypeReadWriter<T> for usage by a TypeReaderWriterManager.

System.Numerics.Vectors Support

The VoltRpc.Extension.Vectors package provides support for almost all types provided by System.Numerics.Vectors.

To install it, you can add it to your project's csproj like so:

<ItemGroup>
    <PackageReference Include="VoltRpc.Extension.Vectors" Version="1.1.0" />
</ItemGroup>

Once you have the NuGet package installed, you can use the types by using InstallVectorsExtension() method with the TypeReaderWriterManager.

So for example:

VoltRpc.Communication.Client client = new TCPClient(new IPEndPoint(IPAddress.Loopback, 7767));
client.TypeReaderWriterManager.InstallVectorsExtension();
client.AddService<ITest>();
...

Both the client and host expose their TypeReaderWriterManager using the same field names.

If you wanted to, you can also manually add each type reader/writer.

You can also use the types in your own custom type readers/writers, using the methods provided in <xref:VoltRpc.Extension.Vectors.BufferedReaderVectorsExtensions> and <xref:VoltRpc.Extension.Vectors.BufferedWriterVectorsExtensions>.

System.Memory Support

The VoltRpc.Extension.Memory provides support for Span and Memory. It ONLY adds to the BufferedReader and BufferedWriter. It does NOT add type readers/writers! This package also provides a Span way of reading strings.

To install it, you can add it to your project's csproj like so:

<ItemGroup>
    <PackageReference Include="VoltRpc.Extension.Memory" Version="1.1.0" />
</ItemGroup>

Once you have the NuGet package installed, you can use the methods in <xref:VoltRpc.Extension.Memory.BufferedReaderMemoryExtensions> and <xref:VoltRpc.Extension.Memory.BufferedWriterMemoryExtensions> in your custom type readers/writers.