Returns (name, value) session settings pairs from an options value. From Postgres, see pg_split_opts in postinit.c and process_postgres_switches in postgres.c.
(value: &str)
| 654 | /// From Postgres, see pg_split_opts in postinit.c and process_postgres_switches |
| 655 | /// in postgres.c. |
| 656 | fn parse_options(value: &str) -> Result<Vec<(String, String)>, ()> { |
| 657 | let opts = split_options(value); |
| 658 | let mut pairs = Vec::with_capacity(opts.len()); |
| 659 | let mut seen_prefix = false; |
| 660 | for opt in opts { |
| 661 | if !seen_prefix { |
| 662 | if opt == "-c" { |
| 663 | seen_prefix = true; |
| 664 | } else { |
| 665 | let (key, val) = parse_option(&opt)?; |
| 666 | pairs.push((key.to_owned(), val.to_owned())); |
| 667 | } |
| 668 | } else { |
| 669 | let (key, val) = opt.split_once('=').ok_or(())?; |
| 670 | pairs.push((key.to_owned(), val.to_owned())); |
| 671 | seen_prefix = false; |
| 672 | } |
| 673 | } |
| 674 | Ok(pairs) |
| 675 | } |
| 676 | |
| 677 | /// Returns the parsed key and value from option of the form `--key=value`, `-c |
| 678 | /// key=value`, or `-ckey=value`. Keys replace `-` with `_`. Returns an error if |