Class WireStrings
- Namespace
- DatabentoDotNet.Dbn
- Assembly
- DatabentoDotNet.Dbn.dll
Allocation-free, reflection-free text conversions for the DBN enums that have a wire text form.
public static class WireStrings
- Inheritance
-
WireStrings
- Inherited Members
Remarks
Two distinct groups of enums are covered, and they are not interchangeable:
-
RType, SType, Schema, Encoding,
Compression, ErrorCode, and SystemCode have a real
stringwire form in the Rust source (as_str/FromStr). UseToWireStringand the matchingTryParse{Enum}(e.g. TryParseRType(string?, out RType)) for these — one method per enum rather than a single overload distinguished only by its out parameter's type, because that would make the ordinaryout varcall form ambiguous and fail to compile. -
Side, Action, InstrumentClass,
MatchAlgorithm, UserDefinedInstrument,
SecurityUpdateAction, and TriState have no string wire
form at all in the Rust source — no
as_str, noFromStr, noDisplay. Their only wire/text representation is the raw ASCII byte itself (e.g. Ask isb'A', not a string"ask"). UseToCharfor these; do not invent strings for them.
None of the string conversions are a mechanical ToString().ToLowerInvariant() —
several wire strings insert a hyphen before a leading digit (mbp-1, ohlcv-1s,
cbbo-1m) that a naive case-transition splitter would miss. Every switch below
mirrors the Rust crate's as_str/FromStr match arms verbatim, including the
handful of legacy parse-only aliases upstream still accepts (documented per method).
This is the text/string half of enum conversion. For numeric wire-byte validation (the
equivalent of Rust's TryFrom<u8>/TryFrom<u16>), see
EnumValues — the two failure modes (an unrecognized string vs. an
out-of-range raw byte) are kept on separate call surfaces on purpose, since upstream
represents them as different error types.
Methods
ToChar(Action)
Returns the ASCII character this Action is defined as.
public static char ToChar(this Action value)
Parameters
valueAction
Returns
ToChar(InstrumentClass)
Returns the ASCII character this InstrumentClass is defined as.
public static char ToChar(this InstrumentClass value)
Parameters
valueInstrumentClass
Returns
ToChar(MatchAlgorithm)
Returns the ASCII character this MatchAlgorithm is defined as.
public static char ToChar(this MatchAlgorithm value)
Parameters
valueMatchAlgorithm
Returns
ToChar(SecurityUpdateAction)
Returns the ASCII character this SecurityUpdateAction is defined as.
public static char ToChar(this SecurityUpdateAction value)
Parameters
valueSecurityUpdateAction
Returns
ToChar(Side)
Returns the ASCII character this Side is defined as.
public static char ToChar(this Side value)
Parameters
valueSide
Returns
ToChar(TriState)
Returns the ASCII character this TriState is defined as.
public static char ToChar(this TriState value)
Parameters
valueTriState
Returns
ToChar(UserDefinedInstrument)
Returns the ASCII character this UserDefinedInstrument is defined as.
public static char ToChar(this UserDefinedInstrument value)
Parameters
valueUserDefinedInstrument
Returns
ToWireString(Compression)
Converts value to its DBN wire string.
public static string ToWireString(this Compression value)
Parameters
valueCompression
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined Compression.
ToWireString(Encoding)
Converts value to its DBN wire string.
public static string ToWireString(this Encoding value)
Parameters
valueEncoding
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined Encoding.
ToWireString(ErrorCode)
Converts value to its DBN wire string.
public static string ToWireString(this ErrorCode value)
Parameters
valueErrorCode
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined ErrorCode.
ToWireString(RType)
Converts value to its DBN wire string.
public static string ToWireString(this RType value)
Parameters
valueRType
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined RType.
ToWireString(SType)
Converts value to its DBN wire string.
public static string ToWireString(this SType value)
Parameters
valueSType
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined SType.
ToWireString(Schema)
Converts value to its DBN wire string.
public static string ToWireString(this Schema value)
Parameters
valueSchema
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined Schema.
ToWireString(SystemCode)
Converts value to its DBN wire string.
public static string ToWireString(this SystemCode value)
Parameters
valueSystemCode
Returns
Exceptions
- ArgumentOutOfRangeException
valueis not a defined SystemCode.
TryParseCompression(string?, out Compression)
Tries to parse a DBN wire string into a Compression. No aliases.
public static bool TryParseCompression(string? value, out Compression result)
Parameters
valuestringresultCompression
Returns
TryParseEncoding(string?, out Encoding)
Tries to parse a DBN wire string into an Encoding. Accepts one parse-only
legacy alias that is never emitted by ToWireString(Encoding): dbz
(the pre-rename file extension, → Dbn).
public static bool TryParseEncoding(string? value, out Encoding result)
Parameters
Returns
TryParseErrorCode(string?, out ErrorCode)
Tries to parse a DBN wire string into an ErrorCode. No aliases.
public static bool TryParseErrorCode(string? value, out ErrorCode result)
Parameters
Returns
TryParseRType(string?, out RType)
Tries to parse a DBN wire string into an RType. No aliases.
public static bool TryParseRType(string? value, out RType result)
Parameters
Returns
TryParseSType(string?, out SType)
Tries to parse a DBN wire string into an SType. Accepts four parse-only
legacy aliases that are never emitted by ToWireString(SType):
product_id (→ InstrumentId), native (→
RawSymbol), nasdaq (→ NasdaqSymbol),
and cms (→ CmsSymbol).
public static bool TryParseSType(string? value, out SType result)
Parameters
Returns
TryParseSchema(string?, out Schema)
Tries to parse a DBN wire string into a Schema. No aliases.
public static bool TryParseSchema(string? value, out Schema result)
Parameters
Returns
TryParseSystemCode(string?, out SystemCode)
Tries to parse a DBN wire string into a SystemCode. No aliases.
public static bool TryParseSystemCode(string? value, out SystemCode result)
Parameters
valuestringresultSystemCode