• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / alioth / 18710378963

22 Oct 2025 08:26AM UTC coverage: 22.826% (+3.4%) from 19.409%
18710378963

push

github

Lencerf
ci: collect coverage with llvm-cov

Signed-off-by: Changyuan Lyu <changyuanl@google.com>

326 of 594 branches covered (54.88%)

Branch coverage included in aggregate %.

2997 of 13964 relevant lines covered (21.46%)

21.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/alioth-cli/src/objects.rs
1
// Copyright 2025 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
use std::collections::HashMap;
16

17
use alioth::errors::{DebugTrace, trace_error};
18
use snafu::Snafu;
19

20
pub const DOC_OBJECTS: &str = r#"Supply additional data to other command line flags.
21
* <id>,<value>
22

23
Any value that comes after an equal sign(=) and contains a comma(,)
24
or equal sign can be supplied using this flag. `<id>` must start
25
with `id_` and `<id>` cannot contain any comma or equal sign.
26

27
Example: assuming we are going a add a virtio-blk device backed by
28
`/path/to/disk,2024.img` and a virtio-fs device backed by a
29
vhost-user process listening on socket `/path/to/socket=1`, these
30
2 devices can be expressed in the command line as follows:
31
    --blk path=id_blk --fs vu,socket=id_fs,tag=shared-dir \
32
    -o id_blk,/path/to/disk,2024.img \
33
    -o id_fs,/path/to/socket=1"#;
34

35
#[trace_error]
36
#[derive(Snafu, DebugTrace)]
×
37
#[snafu(module, context(suffix(false)))]
38
pub enum Error {
39
    #[snafu(display("Invalid object key {key:?}, must start with `id_`"))]
40
    InvalidKey { key: String },
41
    #[snafu(display("Key {key:?} showed up more than once"))]
42
    DuplicateKey { key: String },
43
}
44

45
pub fn parse_objects(objects: &[String]) -> Result<HashMap<&str, &str>, Error> {
×
46
    let mut map = HashMap::new();
×
47
    for obj_s in objects {
×
48
        let (key, val) = obj_s.split_once(',').unwrap_or((obj_s, ""));
×
49
        if !key.starts_with("id_") {
×
50
            return error::InvalidKey {
×
51
                key: key.to_owned(),
×
52
            }
×
53
            .fail();
×
54
        }
×
55
        if map.insert(key, val).is_some() {
×
56
            return error::DuplicateKey {
×
57
                key: key.to_owned(),
×
58
            }
×
59
            .fail();
×
60
        }
×
61
    }
62
    Ok(map)
×
63
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc