fn parse_record(input: Node) -> Result<Record> {
        assert_eq!(input.as_rule(), Rule::record);

        let mut record = Record {
            name: None,
            ttl: None,
            class: None,
            resource: Resource::ANY,
        };

        // All the assert! are due to programming errors, hopefully
        // never due to a parsing error.

        // We would prefer to use match_nodes! but we need to match the
        // various children in any order. This is due to the near ambigious
        // syntax of the resource record entry.
        for node in input.into_children() {
            let rule = node.as_rule();
            match rule {
                Rule::domain => {
                    assert!(record.name.is_none(), "record domain was set twice");

                    record.name = Some(Self::domain(node)?.to_string())
                }
                Rule::duration => {
                    assert!(record.ttl.is_none(), "record ttl was set twice");

                    record.ttl = Some(Self::duration(node)?)
                }
                Rule::class => {
                    assert!(record.class.is_none(), "record class was set twice");

                    record.class = Some(Self::class(node)?)
                }

                _ => {
                    // Rule::resource have many aliases, try one of them.
                    match Self::rule_alias(rule) {
                        AliasedRule::resource => {
                            assert!(
                                record.resource == Resource::ANY,
                                "record resource was set twice"
                            );

                            record.resource = Self::resource(node)?
                        }

                        _ => panic!("Unexpected token: {:?} '{:?}'", rule, node.as_str()),
                    }
                }
            }
        }

        // By the end atleast this should be set
        assert_ne!(record.resource, Resource::ANY);

        Ok(record)
    }
// parse_record does the heavy lifting parsing a single record entry.
// This is in a seperate ZoneParser impl, due to limitations with
// `#[pest_consume::parser]` which does not allow aliased methods to be
// called, or used in match_nodes.
parse_record does the heavy lifting parsing a single record entry.
This is in a seperate ZoneParser impl, due to limitations with
`#[pest_consume::parser]` which does not allow aliased methods to be
called, or used in match_nodes.
parse_record does the heavy lifting parsing a single record entry . This is in a seperate ZoneParser impl due to limitations with ` # [ pest_consume :: parser ] ` which does not allow aliased methods to be called or used in match_nodes .
fn parse_record(input: Node) -> Result<Record> {
        assert_eq!(input.as_rule(), Rule::record);
        let mut record = Record {
            name: None,
            ttl: None,
            class: None,
            resource: Resource::ANY,
        };
        // All the assert! are due to programming errors, hopefully
        // never due to a parsing error.
        // We would prefer to use match_nodes! but we need to match the
        // various children in any order. This is due to the near ambigious
        // syntax of the resource record entry.
        for node in input.into_children() {
            let rule = node.as_rule();
            match rule {
                Rule::domain => {
                    assert!(record.name.is_none(), "record domain was set twice");
                    record.name = Some(Self::domain(node)?.to_string())
                }
                Rule::duration => {
                    assert!(record.ttl.is_none(), "record ttl was set twice");
                    record.ttl = Some(Self::duration(node)?)
                }
                Rule::class => {
                    assert!(record.class.is_none(), "record class was set twice");
                    record.class = Some(Self::class(node)?)
                }
                _ => {
                    // Rule::resource have many aliases, try one of them.
                    match Self::rule_alias(rule) {
                        AliasedRule::resource => {
                            assert!(
                                record.resource == Resource::ANY,
                                "record resource was set twice"
                            );
                            record.resource = Self::resource(node)?
                        }
                        _ => panic!("Unexpected token: {:?} '{:?}'", rule, node.as_str()),
                    }
                }
            }
        }
        // By the end atleast this should be set
        assert_ne!(record.resource, Resource::ANY);
        Ok(record)
    }
fn parse_record ( input : Node ) -> Result < Record > { assert_eq ! ( input as_rule ( ) Rule record ) ; let mut record = Record { name : None , ttl : None , class : None , resource : Resource :: ANY , } ; // All the assert! are due to programming errors, hopefully // never due to a parsing error. // We would prefer to use match_nodes! but we need to match the // various children in any order. This is due to the near ambigious // syntax of the resource record entry. for node in input . into_children ( ) { let rule = node . as_rule ( ) ; match rule { Rule :: domain => { assert ! ( record name is_none ( ) " " ) ; record . name = Some ( Self :: domain ( node ) ? . to_string ( ) ) } Rule :: duration => { assert ! ( record ttl is_none ( ) " " ) ; record . ttl = Some ( Self :: duration ( node ) ? ) } Rule :: class => { assert ! ( record class is_none ( ) " " ) ; record . class = Some ( Self :: class ( node ) ? ) } _ => { // Rule::resource have many aliases, try one of them. match Self :: rule_alias ( rule ) { AliasedRule :: resource => { assert ! ( record resource Resource ANY " " ) ; record . resource = Self :: resource ( node ) ? } _ => panic ! ( " " rule node as_str ( ) ) , } } } } // By the end atleast this should be set assert_ne ! ( record resource Resource ANY ) ; Ok ( record ) }
parse_record does the heavy lifting parsing a single record entry.
parse_record does the heavy lifting parsing a single record entry .
input
Node