simple/
simple.rs

1extern crate clam_client;
2
3use clam_client::client::ClamClient;
4use clam_client::response::ClamScanResult;
5use std::env;
6
7fn main() {
8    if let Some(path) = env::args().nth(1) {
9        let client = ClamClient::new("127.0.0.1", 3310).unwrap();
10        println!("Scanning: {}", path);
11        if let Ok(results) = client.scan_path(&path, true) {
12            for result in results.iter() {
13                match result {
14                    ClamScanResult::Ok => println!("File {} is OK!", path),
15                    ClamScanResult::Found(location, virus) => {
16                        println!("\tFound virus: '{}' in {}", virus, location)
17                    }
18                    ClamScanResult::Error(err) => println!("Received error from ClamAV: {}", err),
19                }
20            }
21        }
22    } else {
23        println!("USAGE: cargo run --example simple \"<file_path>\"");
24    }
25}