Skip to main content

BashCodec

Trait BashCodec 

Source
pub trait BashCodec {
    // Required methods
    fn emit(&self, val: &BashVal) -> Vec<String>;
    fn parse(
        &self,
        words: &[String],
        schema: &Schema,
    ) -> Result<BashVal, ParseError>;

    // Provided methods
    fn emit_literal(&self, val: &BashVal) -> String { ... }
    fn parse_literal(
        &self,
        input: &str,
        schema: &Schema,
    ) -> Result<BashVal, ParseError> { ... }
    fn rows(&self, input: &str) -> Result<Vec<Vec<String>>, ParseError> { ... }
}

Required Methods§

Source

fn emit(&self, val: &BashVal) -> Vec<String>

The value’s own depth decides the encoding, so there is nothing to disagree with and nothing to fail.

Source

fn parse( &self, words: &[String], schema: &Schema, ) -> Result<BashVal, ParseError>

A Schema says how many layers of quoting to peel, which the text alone does not.

Provided Methods§

Source

fn emit_literal(&self, val: &BashVal) -> String

A complete bash array literal: (w1 w2 …), each scalar single-quoted.

Source

fn parse_literal( &self, input: &str, schema: &Schema, ) -> Result<BashVal, ParseError>

Source

fn rows(&self, input: &str) -> Result<Vec<Vec<String>>, ParseError>

A two-dimensional literal as its rows: ("'a' 'b'" "'c'")[["a", "b"], ["c"]]. One dimension needs no codec — see parse_array.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§