Interface ICStructFixedMapped<TSelf>
- Namespace
- CStructSharp
- Assembly
- CStructSharp.dll
The direct read and write of a mapped class bound to one fixed-layout struct, which the source generator emits
for a [CStructMapped(Layout = "...")] class whose layout struct has a build-time offset for every member.
ReadValue<T> and Serialize of a whole struct from memory use them instead of building a
StructValue when the layout of the call has the same FixedLayoutFingerprint.
public interface ICStructFixedMapped<TSelf> where TSelf : ICStructFixedMapped<TSelf>
Type Parameters
TSelfThe mapped class.
Remarks
An implementation promises the results of the class's ICStructMapped<TSelf> members over a struct of that layout: the same property values from the same bytes, and the same bytes from the same instance. It returns false for anything it does not handle exactly that way, and the caller then takes the ICStructMapped<TSelf> route. Hand-written implementations take on that promise; the generated ones are held to it by the repository's parity tests.
Properties
FixedLayoutFingerprint
Gets the fingerprint of the layout struct the direct members were generated for.
public static abstract ulong FixedLayoutFingerprint { get; }
Property Value
Methods
TryReadFixed(ReadOnlySpan<byte>, bool, out TSelf)
Reads an instance from the struct's bytes, each property from its member's constant offset.
public static abstract bool TryReadFixed(ReadOnlySpan<byte> source, bool trimFixedText, out TSelf value)
Parameters
sourceReadOnlySpan<byte>The struct's bytes, at least its size.
trimFixedTextboolWhether fixed-capacity text drops its trailing NUL padding (TrimFixedText).
valueTSelfThe instance when the method returns true.
Returns
TryWriteFixed(TSelf, Span<byte>)
Writes an instance into the struct's bytes, each property at its member's constant offset.
public static abstract bool TryWriteFixed(TSelf value, Span<byte> target)
Parameters
valueTSelfThe instance.
targetSpan<byte>The struct's bytes, already zero (so padding is written as zeros), at least its size.