Trait arrow_cast::parse::Parser

source ·
pub trait Parser: ArrowPrimitiveType {
    // Required method
    fn parse(string: &str) -> Option<Self::Native>;

    // Provided method
    fn parse_formatted(string: &str, _format: &str) -> Option<Self::Native> { ... }
}
Expand description

Specialized parsing implementations to convert strings to Arrow types.

This is used by csv and json reader and can be used directly as well.

§Example

To parse a string to a Date32Type:

use arrow_cast::parse::Parser;
use arrow_array::types::Date32Type;
let date = Date32Type::parse("2021-01-01").unwrap();
assert_eq!(date, 18628);

To parse a string to a TimestampNanosecondType:

use arrow_cast::parse::Parser;
use arrow_array::types::TimestampNanosecondType;
let ts = TimestampNanosecondType::parse("2021-01-01T00:00:00.123456789Z").unwrap();
assert_eq!(ts, 1609459200123456789);

Required Methods§

source

fn parse(string: &str) -> Option<Self::Native>

Provided Methods§

source

fn parse_formatted(string: &str, _format: &str) -> Option<Self::Native>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Parser for Date32Type

source§

fn parse(string: &str) -> Option<i32>

source§

fn parse_formatted(string: &str, format: &str) -> Option<i32>

source§

impl Parser for Date64Type

source§

fn parse(string: &str) -> Option<i64>

source§

fn parse_formatted(string: &str, format: &str) -> Option<i64>

source§

impl Parser for Float16Type

source§

fn parse(string: &str) -> Option<f16>

source§

impl Parser for Float32Type

source§

fn parse(string: &str) -> Option<f32>

source§

impl Parser for Float64Type

source§

fn parse(string: &str) -> Option<f64>

source§

impl Parser for Int8Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for Int16Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for Int32Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for Int64Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for Time32MillisecondType

source§

fn parse(string: &str) -> Option<Self::Native>

source§

fn parse_formatted(string: &str, format: &str) -> Option<Self::Native>

source§

impl Parser for Time32SecondType

source§

fn parse(string: &str) -> Option<Self::Native>

source§

fn parse_formatted(string: &str, format: &str) -> Option<Self::Native>

source§

impl Parser for Time64MicrosecondType

source§

fn parse(string: &str) -> Option<Self::Native>

source§

fn parse_formatted(string: &str, format: &str) -> Option<Self::Native>

source§

impl Parser for Time64NanosecondType

source§

fn parse(string: &str) -> Option<Self::Native>

source§

fn parse_formatted(string: &str, format: &str) -> Option<Self::Native>

source§

impl Parser for TimestampMicrosecondType

source§

fn parse(string: &str) -> Option<i64>

source§

impl Parser for TimestampMillisecondType

source§

fn parse(string: &str) -> Option<i64>

source§

impl Parser for TimestampNanosecondType

source§

fn parse(string: &str) -> Option<i64>

source§

impl Parser for TimestampSecondType

source§

fn parse(string: &str) -> Option<i64>

source§

impl Parser for UInt8Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for UInt16Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for UInt32Type

source§

fn parse(string: &str) -> Option<Self::Native>

source§

impl Parser for UInt64Type

source§

fn parse(string: &str) -> Option<Self::Native>

Implementors§