fapolicy_rules/parser/marker.rs
1/*
2 * Copyright Concurrent Technologies Corporation 2021
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 */
8
9use std::path::PathBuf;
10
11use nom::bytes::complete::{is_not, tag};
12use nom::sequence::delimited;
13
14use crate::parser::parse::{StrTrace, TraceResult};
15
16pub(crate) fn parse(i: StrTrace) -> TraceResult<PathBuf> {
17 // todo;; fail if the path contains a directory component; we should expect filename only in the marker
18 delimited(tag("["), is_not("]"), tag("]"))(i).map(|(r, path)| (r, PathBuf::from(path.current)))
19}