pub struct ClamdClient<T: ToSocketAddrs + ToOwned<Owned = T>> { /* private fields */ }Expand description
Asynchronous, tokio based client for clamd. Use ClamdClientBuilder to build.
At the moment, this will always open a new TCP connection for each command executed.
There are plans to also include an option to reuse / keep alive connections but that is a TODO.
For more information about the various commands please also consult the man pages for clamd (man clamd).
§Example
let address = "127.0.0.1:3310";
let mut clamd_client = ClamdClientBuilder::tcp_socket(address).build();
clamd_client.ping().await?;Implementations§
Source§impl<T: ToSocketAddrs + ToOwned<Owned = T>> ClamdClient<T>
impl<T: ToSocketAddrs + ToOwned<Owned = T>> ClamdClient<T>
Sourcepub async fn ping(&mut self) -> Result<(), ClamdError>
pub async fn ping(&mut self) -> Result<(), ClamdError>
Ping clamd. If it responds normally (with PONG) this function returns Ok(()), otherwise
returns with error.
Sourcepub async fn version(&mut self) -> Result<String, ClamdError>
pub async fn version(&mut self) -> Result<String, ClamdError>
Get clamd version string.
Sourcepub async fn reload(&mut self) -> Result<(), ClamdError>
pub async fn reload(&mut self) -> Result<(), ClamdError>
Reload clamd.
Sourcepub async fn stats(&mut self) -> Result<String, ClamdError>
pub async fn stats(&mut self) -> Result<String, ClamdError>
Get clamd stats.
Sourcepub async fn shutdown(self) -> Result<(), ClamdError>
pub async fn shutdown(self) -> Result<(), ClamdError>
Shutdown clamd. Careful: There is no way to start clamd again from this library.
Sourcepub async fn scan_reader<R: AsyncRead + AsyncReadExt + Unpin>(
&mut self,
to_scan: R,
) -> Result<(), ClamdError>
pub async fn scan_reader<R: AsyncRead + AsyncReadExt + Unpin>( &mut self, to_scan: R, ) -> Result<(), ClamdError>
Upload bytes to check it for viruses. This will chunk the
reader with a chunk size defined in the
ClamdClientBuilder. Only if clamd resonds with stream: OK
(and thus clamd found the bytes to not include virus
signatures) this function will return Ok(()). In all other
cases returns an error.
§Errors
If the scan was sucessful
but seems to have found a virus signature this returns
ClamdError::ScanError with the scan result. See ClamdError for more
information.
Sourcepub async fn scan_bytes(&mut self, to_scan: &[u8]) -> Result<(), ClamdError>
pub async fn scan_bytes(&mut self, to_scan: &[u8]) -> Result<(), ClamdError>
Convienence method to scan a bytes slice. Wraps ClamdClient::scan_reader, so see there
for more information.
Sourcepub async fn scan_file(
&mut self,
path_to_scan: impl AsRef<Path>,
) -> Result<(), ClamdError>
pub async fn scan_file( &mut self, path_to_scan: impl AsRef<Path>, ) -> Result<(), ClamdError>
Convienence method to directly scan a file under the given
path. This will read the file and stream it to clamd. Wraps
ClamdClient::scan_reader, so see there for more information.