Interface ICStructGenerated<TSelf>
- Namespace
- CStructSharp
- Assembly
- CStructSharp.dll
Implemented by the root class the [CStructLayout] generator emits, so generic code can accept any
generated root: the runtime CStruct for the same layout, the root name, and the generated
span operations.
public interface ICStructGenerated<TSelf> where TSelf : ICStructGenerated<TSelf>
Type Parameters
TSelfThe generated root class.
Properties
Layout
Gets the runtime layout the class was generated from (built lazily on first use).
public static abstract CStruct Layout { get; }
Property Value
RootName
Gets the declaration name the class corresponds to.
public static abstract string RootName { get; }
Property Value
Methods
Parse(ReadOnlySpan<byte>, ReadOptions?)
Parses one value from source with the generated reader.
public static abstract TSelf Parse(ReadOnlySpan<byte> source, ReadOptions? options = null)
Parameters
sourceReadOnlySpan<byte>The bytes; offset 0 is coordinate zero.
optionsReadOptionsThe read options; null uses the documented defaults.
Returns
- TSelf
The parsed value.
Serialize(TSelf, Span<byte>, WriteOptions?)
Serializes value into destination with the generated writer.
public static abstract int Serialize(TSelf value, Span<byte> destination, WriteOptions? options = null)
Parameters
valueTSelfThe value to encode.
destinationSpan<byte>The bytes to write into.
optionsWriteOptionsThe write options; null uses the documented defaults.
Returns
- int
The number of bytes written.
TryParse(ReadOnlySpan<byte>, out TSelf, out CStructException?, ReadOptions?)
Parses one value without throwing for a read, path, or limit failure: false and the failure the throwing form would have raised. Cancellation and argument errors throw as in Parse(ReadOnlySpan<byte>, ReadOptions?).
public static abstract bool TryParse(ReadOnlySpan<byte> source, out TSelf value, out CStructException? failure, ReadOptions? options = null)
Parameters
sourceReadOnlySpan<byte>The bytes; offset 0 is coordinate zero.
valueTSelfThe parsed value, or null when the read failed.
failureCStructExceptionThe failure, or null.
optionsReadOptionsThe read options; null uses the documented defaults.
Returns
- bool
Whether the read succeeded.