RTI Connext C# API Version 7.2.0
Rti.Dds.Topics.SerializerExtensions Class Reference

Provides additional operations for ISerializer<T> More...

Static Public Member Functions

static Span< byte > Serialize< T > (this ISerializer< T > self, T sample, Span< byte > buffer)
 Serializes a data sample into a byte span More...
 
static T Deserialize< T > (this ISerializer< T > self, Span< byte > buffer)
 Deserializes a data sample from a byte span More...
 

Detailed Description

Provides additional operations for ISerializer<T>

Note
These methods require the package Rti.ConnextDds.Extra. This package requires .NET Standard 2.1 (while Rti.ConnextDds only requires .NET Standard 2.0).

Member Function Documentation

◆ Serialize< T >()

static Span< byte > Rti.Dds.Topics.SerializerExtensions.Serialize< T > ( this ISerializer< T >  self,
sample,
Span< byte >  buffer 
)
inlinestatic

Serializes a data sample into a byte span

Parameters
selfThis ISerializer object (this is an extension method)
sampleA data sample
bufferA byte span with enough space to contain the serialized data. This operation throws DdsException if the data doesn't fit. You can obtain the exact size required for this sample with ISerializer<T>.GetSerializedSampleSize or a size that is guaranteed to suffice for any sample of this type with ISerializer<T>.GetSerializedSampleMaxSize.
Template Parameters
TThe type of the data sample
Returns
A slice of the input span with the exact serialized buffer

◆ Deserialize< T >()

static T Rti.Dds.Topics.SerializerExtensions.Deserialize< T > ( this ISerializer< T >  self,
Span< byte >  buffer 
)
inlinestatic

Deserializes a data sample from a byte span

Parameters
selfThis ISerializer object (this is an extension method)
bufferA byte span containing the serialized data
Template Parameters
TThe type of the data sample
Returns
A new data sample created by deserializing the buffer