Class ReferenceWireStrings
- Namespace
- DatabentoDotNet.Reference
- Assembly
- DatabentoDotNet.Reference.dll
Wire-code conversions for the nine closed reference enums, and the argument for why they are
enums at all.
public static class ReferenceWireStrings
- Inheritance
-
ReferenceWireStrings
- Inherited Members
Remarks
These nine are closed, and the ten types behind IReferenceCode<TSelf> are
not. The line is wire alphabet against data dictionary, not #[repr(u8)] against
String. A single-byte alphabet is closed because a new value in it is a wire-format
change; a code that comes out of Databento's growing corporate-actions dictionary is not.
Probing corporate_actions.list_enums before any of this was written found eight of these
nine exactly current against the live server, and found upstream already behind it on
two of the sets it models as closed — SecurityType at 30 codes of 64, and
Frequency at 14 of 16. Those two moved to the open carrier, and OutturnStyle moved
with them despite matching the server exactly today, because the rule is where a vocabulary
comes from rather than how many values it currently holds. ROADMAP.md §6 records the probe.
Each enum keeps upstream's byte backing: public enum T : byte with Member =
(byte)'C', exactly as Action is declared. Three reasons,
and none of them is habit.
-
It is upstream's own representation —
#[repr(u8)]withCancelled = b'C'— and the porting rules make the Rust source authoritative for wire format. -
It makes
default(T)an undefined value. Byte 0 is not a code any of these alphabets uses, so a response field that was never set cannot pass for a real member. A plain 0-based enum would read a missing field as its first member —Fraction.Cash,PaymentType.CashAndStock— which is the silent kind of wrong this library exists to prevent. - The codec already models char-coded enums this way, so a reader who knows Action already knows these.
What differs from the codec's char enums is the wire, not the type. On the DBN wire a
Side is the raw ASCII byte, and that byte is its only
representation — there is no text form to parse. Here the byte never appears: the reference API
is JSON, and it carries a one-character string ("C"). So these enums do have a
text form, it is exactly one character long, and a string of any other length is as unrecognised
as an unknown letter. The Json/ converters are where that is enforced.
The contract of the two conversions, which is the codec's contract restated.
ToChar is (char)value and does not validate: hand it a value cast from an
undefined byte and you get that byte back as a character, exactly as
DatabentoDotNet.Dbn.WireStrings.ToChar does. It is not the guard, and the round-trip
identity the tests assert — code → enum → code — is a claim about the defined members,
which is all it can be. TryParse{Enum} is the guard: it answers false
for anything the alphabet does not contain and never throws.
One TryParse method per enum rather than an overload set distinguished only by the
out parameter's type, for the reason
DatabentoDotNet.Historical.MetadataWireStrings gives: an overload set of that shape makes
the ordinary out var call form ambiguous and fails to compile.
There is deliberately no ToWireString here. A one-character string is what the converters
write, and they write it from the char; a second surface that allocates a
one-character string would have no caller.
Methods
ToChar(Action)
Returns the ASCII character this Action is defined as.
public static char ToChar(this Action value)
Parameters
valueActionThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(AdjustmentStatus)
Returns the ASCII character this AdjustmentStatus is defined as.
public static char ToChar(this AdjustmentStatus value)
Parameters
valueAdjustmentStatusThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(Fraction)
Returns the ASCII character this Fraction is defined as.
public static char ToChar(this Fraction value)
Parameters
valueFractionThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(GlobalStatus)
Returns the ASCII character this GlobalStatus is defined as.
public static char ToChar(this GlobalStatus value)
Parameters
valueGlobalStatusThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(ListingSource)
Returns the ASCII character this ListingSource is defined as.
public static char ToChar(this ListingSource value)
Parameters
valueListingSourceThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(ListingStatus)
Returns the ASCII character this ListingStatus is defined as.
public static char ToChar(this ListingStatus value)
Parameters
valueListingStatusThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(MandVolu)
Returns the ASCII character this MandVolu is defined as.
public static char ToChar(this MandVolu value)
Parameters
valueMandVoluThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(PaymentType)
Returns the ASCII character this PaymentType is defined as.
public static char ToChar(this PaymentType value)
Parameters
valuePaymentTypeThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
ToChar(Voting)
Returns the ASCII character this Voting is defined as.
public static char ToChar(this Voting value)
Parameters
valueVotingThe value.
Returns
- char
The wire code. Not validated — see the type's remarks.
TryParseAction(char, out Action)
Parses an Action wire code.
public static bool TryParseAction(char value, out Action result)
Parameters
Returns
TryParseAdjustmentStatus(char, out AdjustmentStatus)
Parses an AdjustmentStatus wire code.
public static bool TryParseAdjustmentStatus(char value, out AdjustmentStatus result)
Parameters
valuecharThe one-character wire code.
resultAdjustmentStatusThe parsed value, or default.
Returns
TryParseFraction(char, out Fraction)
Parses a Fraction wire code.
public static bool TryParseFraction(char value, out Fraction result)
Parameters
Returns
TryParseGlobalStatus(char, out GlobalStatus)
Parses a GlobalStatus wire code.
public static bool TryParseGlobalStatus(char value, out GlobalStatus result)
Parameters
valuecharThe one-character wire code.
resultGlobalStatusThe parsed value, or default.
Returns
TryParseListingSource(char, out ListingSource)
Parses a ListingSource wire code.
public static bool TryParseListingSource(char value, out ListingSource result)
Parameters
valuecharThe one-character wire code.
resultListingSourceThe parsed value, or default.
Returns
TryParseListingStatus(char, out ListingStatus)
Parses a ListingStatus wire code.
public static bool TryParseListingStatus(char value, out ListingStatus result)
Parameters
valuecharThe one-character wire code.
resultListingStatusThe parsed value, or default.
Returns
TryParseMandVolu(char, out MandVolu)
Parses a MandVolu wire code.
public static bool TryParseMandVolu(char value, out MandVolu result)
Parameters
Returns
TryParsePaymentType(char, out PaymentType)
Parses a PaymentType wire code.
public static bool TryParsePaymentType(char value, out PaymentType result)
Parameters
valuecharThe one-character wire code.
resultPaymentTypeThe parsed value, or default.
Returns
TryParseVoting(char, out Voting)
Parses a Voting wire code.
public static bool TryParseVoting(char value, out Voting result)