Header menu logo Xanthos

RecordParser Module

Core parsing functions for JV-Link fixed-length records.

This module provides low-level parsing utilities used by specific record parsers (RA.fs, UM.fs, etc.) to extract typed values from binary data.

Types

Type Description

FieldValue

Represents a parsed field value with type information.

ParseBuilder

Computation expression builder for Result with RecordParseError.

RecordParseError

Errors that can occur during record parsing.

RichFieldValue

Represents a parsed field value with explicit missing indicators.

XanthosParseBuilder

Computation expression builder for Result with XanthosError.

Functions and values

Function or value Description

extractBytes data offset length

Full Usage: extractBytes data offset length

Parameters:
    data : byte[] - The source byte array.
    offset : int - Zero-based starting position.
    length : int - Number of bytes to extract.

Returns: Result<byte[], RecordParseError> Ok with the byte slice, or Error if the slice would exceed data bounds.

Extracts a byte slice from record data at the specified offset and length.

data : byte[]

The source byte array.

offset : int

Zero-based starting position.

length : int

Number of bytes to extract.

Returns: Result<byte[], RecordParseError>

Ok with the byte slice, or Error if the slice would exceed data bounds.

getBool fields name

Full Usage: getBool fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: bool The boolean value, or false if field not found.

Gets a boolean flag value from parsed fields (defaults to false).

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: bool

The boolean value, or false if field not found.

getBytes fields name

Full Usage: getBytes fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: byte[] option Some byte array if present, None otherwise.

Gets an optional raw bytes field value from parsed fields.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: byte[] option

Some byte array if present, None otherwise.

getCode fields name

Full Usage: getCode fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: 'T option Some enum value if present and valid, None otherwise.

Gets an optional code table value, parsed as an enum type.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: 'T option

Some enum value if present and valid, None otherwise.

getDate fields name

Full Usage: getDate fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: DateTime option Some DateTime if present and valid, None otherwise.

Gets an optional date field value from parsed fields.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: DateTime option

Some DateTime if present and valid, None otherwise.

getDecimal fields name

Full Usage: getDecimal fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: decimal option Some decimal if present and valid, None otherwise.

Gets an optional decimal field value from parsed fields.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: decimal option

Some decimal if present and valid, None otherwise.

getInt fields name

Full Usage: getInt fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: int option Some int if present and valid, None otherwise.

Gets an optional integer field value from parsed fields.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: int option

Some int if present and valid, None otherwise.

getRecordType data

Full Usage: getRecordType data

Parameters:
    data : byte[] - The source record byte array.

Returns: string The record type string (e.g., "RA", "UM"), or empty string if data is too short.

Extracts the 2-byte record type identifier from record data.

data : byte[]

The source record byte array.

Returns: string

The record type string (e.g., "RA", "UM"), or empty string if data is too short.

getRequiredText fields name

Full Usage: getRequiredText fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: Result<string, RecordParseError> Ok with the text value, or Error if missing/empty.

Gets a required text field value, returning Error if missing or empty.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: Result<string, RecordParseError>

Ok with the text value, or Error if missing/empty.

getRichBool name fields

Full Usage: getRichBool name fields

Parameters:
Returns: bool option

Gets a boolean value from RichFieldValue map.

name : string
fields : Map<string, RichFieldValue>
Returns: bool option

getRichBytes name fields

Full Usage: getRichBytes name fields

Parameters:
Returns: byte[] option

Gets raw bytes from RichFieldValue map.

name : string
fields : Map<string, RichFieldValue>
Returns: byte[] option

getRichCode name fields

Full Usage: getRichCode name fields

Parameters:
Returns: 'T option

Gets and parses a code value as an enum from RichFieldValue map.

name : string
fields : Map<string, RichFieldValue>
Returns: 'T option

getRichDate name fields

Full Usage: getRichDate name fields

Parameters:
Returns: DateTime option

Gets a date value from RichFieldValue map (None for missing or RDateMissing).

name : string
fields : Map<string, RichFieldValue>
Returns: DateTime option

getRichDecimal name fields

Full Usage: getRichDecimal name fields

Parameters:
Returns: decimal option

Gets a decimal value from RichFieldValue map (None for missing or RDecimalMissing).

name : string
fields : Map<string, RichFieldValue>
Returns: decimal option

getRichInt name fields

Full Usage: getRichInt name fields

Parameters:
Returns: int option

Gets an integer value from RichFieldValue map (None for missing or RIntMissing).

name : string
fields : Map<string, RichFieldValue>
Returns: int option

getRichText name fields

Full Usage: getRichText name fields

Parameters:
Returns: string option

Gets a text value from RichFieldValue map.

name : string
fields : Map<string, RichFieldValue>
Returns: string option

getText fields name

Full Usage: getText fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: string option Some text if present and non-empty, None otherwise.

Gets an optional text field value from parsed fields.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: string option

Some text if present and non-empty, None otherwise.

parse

Full Usage: parse

Returns: ParseBuilder

Computation expression instance for parsing with RecordParseError.

Returns: ParseBuilder

parseDate bytes format

Full Usage: parseDate bytes format

Parameters:
    bytes : byte[] - The source bytes.
    format : string - DateTime format string (e.g., "yyyyMMdd").

Returns: DateTime option

Parses a byte array as a date using the specified format string.

bytes : byte[]

The source bytes.

format : string

DateTime format string (e.g., "yyyyMMdd").

Returns: DateTime option

parseDecimal bytes precision

Full Usage: parseDecimal bytes precision

Parameters:
    bytes : byte[] - The source bytes.
    precision : int - Number of decimal places (value is divided by 10^precision).

Returns: decimal option

Parses a byte array as a fixed-point decimal with the specified precision.

bytes : byte[]

The source bytes.

precision : int

Number of decimal places (value is divided by 10^precision).

Returns: decimal option

parseField data spec

Full Usage: parseField data spec

Parameters:
    data : byte[] - The source record byte array.
    spec : FieldSpec - The field specification defining offset, length, and encoding.

Returns: Result<FieldValue, RecordParseError> Ok with the parsed FieldValue, or Error on extraction failure.

Parses a single field from record data using a field specification. Uses Option types to represent missing values.

data : byte[]

The source record byte array.

spec : FieldSpec

The field specification defining offset, length, and encoding.

Returns: Result<FieldValue, RecordParseError>

Ok with the parsed FieldValue, or Error on extraction failure.

parseFieldRich data spec

Full Usage: parseFieldRich data spec

Parameters:
    data : byte[] - The source record byte array.
    spec : FieldSpec - The field specification defining offset, length, and encoding.

Returns: Result<RichFieldValue, RecordParseError> Ok with the parsed RichFieldValue, or Error on extraction failure.

Parses a single field from record data using a field specification. Returns a RichFieldValue that distinguishes between zero and missing values.

data : byte[]

The source record byte array.

spec : FieldSpec

The field specification defining offset, length, and encoding.

Returns: Result<RichFieldValue, RecordParseError>

Ok with the parsed RichFieldValue, or Error on extraction failure.

parseFields data specs

Full Usage: parseFields data specs

Parameters:
    data : byte[] - The source record byte array.
    specs : FieldSpec list - List of field specifications to parse.

Returns: Result<Map<string, FieldValue>, RecordParseError> Ok with a Map of field names to FieldValues, or Error on first parse failure.

Parses multiple fields from record data according to a list of specifications.

data : byte[]

The source record byte array.

specs : FieldSpec list

List of field specifications to parse.

Returns: Result<Map<string, FieldValue>, RecordParseError>

Ok with a Map of field names to FieldValues, or Error on first parse failure.

parseFieldsRich data specs

Full Usage: parseFieldsRich data specs

Parameters:
    data : byte[] - The source record byte array.
    specs : FieldSpec list - List of field specifications to parse.

Returns: Result<Map<string, RichFieldValue>, RecordParseError> Ok with a Map of field names to RichFieldValues, or Error on first parse failure.

Parses multiple fields from record data, returning RichFieldValue for each.

data : byte[]

The source record byte array.

specs : FieldSpec list

List of field specifications to parse.

Returns: Result<Map<string, RichFieldValue>, RecordParseError>

Ok with a Map of field names to RichFieldValues, or Error on first parse failure.

parseFieldsXanthos data specs

Full Usage: parseFieldsXanthos data specs

Parameters:
Returns: Result<Map<string, FieldValue>, XanthosError>

Parse fields returning XanthosError (for use with parseRecord builder).

data : byte[]
specs : FieldSpec list
Returns: Result<Map<string, FieldValue>, XanthosError>

parseFlag bytes

Full Usage: parseFlag bytes

Parameters:
    bytes : byte[]

Returns: bool

Parses a byte array as a boolean flag ("1" = true).

bytes : byte[]
Returns: bool

parseInt bytes

Full Usage: parseInt bytes

Parameters:
    bytes : byte[]

Returns: int option

Parses a byte array as an integer. Returns None if empty or invalid.

bytes : byte[]
Returns: int option

parseRecord

Full Usage: parseRecord

Returns: XanthosParseBuilder

Computation expression instance for parsing with XanthosError.

Returns: XanthosParseBuilder

requireInt fields name

Full Usage: requireInt fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: Result<int, XanthosError> Ok with the int value, or Error(XanthosError) if missing/invalid.

Gets a required integer field value, returning XanthosError if missing.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: Result<int, XanthosError>

Ok with the int value, or Error(XanthosError) if missing/invalid.

requireText fields name

Full Usage: requireText fields name

Parameters:
    fields : Map<string, FieldValue> - Map of parsed field values.
    name : string - Field name to retrieve.

Returns: Result<string, XanthosError> Ok with the text value, or Error(XanthosError) if missing/empty.

Gets a required text field value, returning XanthosError if missing.

fields : Map<string, FieldValue>

Map of parsed field values.

name : string

Field name to retrieve.

Returns: Result<string, XanthosError>

Ok with the text value, or Error(XanthosError) if missing/empty.

toXanthosError error

Full Usage: toXanthosError error

Parameters:
Returns: XanthosError A XanthosError (ValidationError) with a descriptive message.

Converts a RecordParseError to a XanthosError for unified error handling.

error : RecordParseError

The record parse error to convert.

Returns: XanthosError

A XanthosError (ValidationError) with a descriptive message.

tryGetRich name fields

Full Usage: tryGetRich name fields

Parameters:
Returns: RichFieldValue option

Attempts to get a RichFieldValue by name from the fields map.

name : string
fields : Map<string, RichFieldValue>
Returns: RichFieldValue option

Type something to start searching.