1extern crate clam_client;
2
3use clam_client::client::ClamClient;
4use clam_client::response::ClamScanResult;
5use std::env;
6use std::fs::File;
7
8fn main() {
9 if let Some(path) = env::args().nth(1) {
10 let client = ClamClient::new("127.0.0.1", 3310).unwrap();
11 let file = File::open(&path).unwrap();
12
13 match client.scan_stream(file) {
14 Ok(result) => match result {
15 ClamScanResult::Ok => println!("File {} is OK!", path),
16 ClamScanResult::Found(location, virus) => {
17 println!("Found virus: '{}' in {}", virus, location)
18 }
19 ClamScanResult::Error(err) => println!("Received error from ClamAV: {}", err),
20 },
21 Err(e) => println!("A network error occurred whilst talking to ClamAV:\n{}", e),
22 }
23 } else {
24 println!("USAGE: cargo run --example stream \"<file_path>\"");
25 }
26}