Ferrous API Reference

All Types / Ferrous.Results

class ResultJsonConverter<T, TError>

public sealed class ResultJsonConverter<T, TError> : JsonConverter<Result<T, TError>>

NativeAOT-compatible JsonConverter<T> for Result<T, TError>. Serializes Ok(v) as {"ok":v} and Err(e) as {"err":e} (Rust serde externally tagged format).

Type Parameters
T
The success value type.
TError
The error value type.

Constructors

public ResultJsonConverter()

Initializes a new converter using the JsonSerializerOptions passed at read/write time.

public ResultJsonConverter(JsonTypeInfo<T> okTypeInfo, JsonTypeInfo<TError> errTypeInfo)

Initializes a new NativeAOT-safe converter using explicit JsonTypeInfo<T> metadata.

Methods

public override Result<T, TError> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, Result<T, TError> value, JsonSerializerOptions options)