Skip to content

Commit

Permalink
Remove deprecated functions and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toblux committed Oct 23, 2024
1 parent 1e7bafa commit 7396407
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 1,308 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The `*_socket` and `*_tcp` functions have been deprecated in favor of more gener

For example,

```rust
```rust,ignore
let clamd_host_address = "localhost:3310";
let result = clamav_client::scan_file_tcp("README.md", clamd_host_address, None);
assert!(result.is_ok());
Expand Down
201 changes: 0 additions & 201 deletions src/async_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,207 +93,6 @@ async fn _scan_stream<
Ok(response)
}

/// Sends a ping request to ClamAV using a Unix socket connection
///
/// This function establishes a Unix socket connection to a ClamAV server at the
/// specified `socket_path` and sends a ping request to it.
///
/// # Example
///
/// ```
/// # #[async_std::main]
/// # async fn main() {
/// let clamd_available = match clamav_client::async_std::ping_socket("/tmp/clamd.socket").await {
/// Ok(ping_response) => ping_response == clamav_client::PONG,
/// Err(_) => false,
/// };
/// # assert!(clamd_available);
/// # }
/// ```
///
#[deprecated(since = "0.5.0", note = "Use `ping` instead")]
#[cfg(unix)]
pub async fn ping_socket<P: AsRef<Path>>(socket_path: P) -> IoResult {
ping(Socket { socket_path }).await
}

/// Scans a file for viruses using a Unix socket connection
///
/// This function reads data from a file located at the specified `file_path`
/// and streams it to a ClamAV server through a Unix socket connection for
/// scanning.
///
/// # Arguments
///
/// * `file_path`: Path to the file to be scanned
/// * `socket_path`: Path to the Unix socket for the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_file` instead")]
#[cfg(unix)]
pub async fn scan_file_socket<P: AsRef<Path>>(
file_path: P,
socket_path: P,
chunk_size: Option<usize>,
) -> IoResult {
scan_file(file_path, Socket { socket_path }, chunk_size).await
}

/// Scans a data buffer for viruses using a Unix socket connection
///
/// This function streams the provided `buffer` data to a ClamAV server through
/// a Unix socket connection for scanning.
///
/// # Arguments
///
/// * `buffer`: The data to be scanned
/// * `socket_path`: The path to the Unix socket of the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_buffer` instead")]
#[cfg(unix)]
pub async fn scan_buffer_socket<P: AsRef<Path>>(
buffer: &[u8],
socket_path: P,
chunk_size: Option<usize>,
) -> IoResult {
scan_buffer(buffer, Socket { socket_path }, chunk_size).await
}

/// Scans a stream for viruses using a Unix socket connection
///
/// This function sends the provided stream to a ClamAV server through a Unix
/// socket connection for scanning.
///
/// # Arguments
///
/// * `input_stream`: The stream to be scanned
/// * `socket_path`: The path to the Unix socket of the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_stream` instead")]
#[cfg(unix)]
pub async fn scan_stream_socket<
S: Stream<Item = Result<bytes::Bytes, std::io::Error>>,
P: AsRef<Path>,
>(
input_stream: S,
socket_path: P,
chunk_size: Option<usize>,
) -> IoResult {
scan_stream(input_stream, Socket { socket_path }, chunk_size).await
}

/// Sends a ping request to ClamAV using a TCP connection
///
/// This function establishes a TCP connection to a ClamAV server at the
/// specified `host_address` and sends a ping request to it.
///
/// # Example
///
/// ```
/// # #[async_std::main]
/// # async fn main() {
/// let clamd_available = match clamav_client::async_std::ping_tcp("localhost:3310").await {
/// Ok(ping_response) => ping_response == clamav_client::PONG,
/// Err(_) => false,
/// };
/// # assert!(clamd_available);
/// # }
/// ```
///
#[deprecated(since = "0.5.0", note = "Use `ping` instead")]
pub async fn ping_tcp<A: ToSocketAddrs>(host_address: A) -> IoResult {
ping(Tcp { host_address }).await
}

/// Scans a file for viruses using a TCP connection
///
/// This function reads data from a file located at the specified `file_path`
/// and streams it to a ClamAV server through a TCP connection for scanning.
///
/// # Arguments
///
/// * `file_path`: The path to the file to be scanned
/// * `host_address`: The address (host and port) of the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_file` instead")]
pub async fn scan_file_tcp<P: AsRef<Path>, A: ToSocketAddrs>(
file_path: P,
host_address: A,
chunk_size: Option<usize>,
) -> IoResult {
scan_file(file_path, Tcp { host_address }, chunk_size).await
}

/// Scans a data buffer for viruses using a TCP connection
///
/// This function streams the provided `buffer` data to a ClamAV server through
/// a TCP connection for scanning.
///
/// # Arguments
///
/// * `buffer`: The data to be scanned
/// * `host_address`: The address (host and port) of the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_buffer` instead")]
pub async fn scan_buffer_tcp<A: ToSocketAddrs>(
buffer: &[u8],
host_address: A,
chunk_size: Option<usize>,
) -> IoResult {
scan_buffer(buffer, Tcp { host_address }, chunk_size).await
}

/// Scans a stream for viruses using a TCP connection
///
/// This function sends the provided stream to a ClamAV server through a TCP
/// connection for scanning.
///
/// # Arguments
///
/// * `input_stream`: The stream to be scanned
/// * `host_address`: The address (host and port) of the ClamAV server
/// * `chunk_size`: An optional chunk size for reading data. If [`None`], a default chunk size is used
///
/// # Returns
///
/// An [`IoResult`] containing the server's response as a vector of bytes
///
#[deprecated(since = "0.5.0", note = "Use `scan_stream` instead")]
pub async fn scan_stream_tcp<
S: Stream<Item = Result<bytes::Bytes, std::io::Error>>,
A: ToSocketAddrs,
>(
input_stream: S,
host_address: A,
chunk_size: Option<usize>,
) -> IoResult {
scan_stream(input_stream, Tcp { host_address }, chunk_size).await
}

/// Use a TCP connection to communicate with a ClamAV server
#[derive(Copy, Clone)]
pub struct Tcp<A: ToSocketAddrs> {
Expand Down
Loading

0 comments on commit 7396407

Please sign in to comment.