- Fix trailing whitespace in kex.rs and s3.rs - Add missing KexProposal import in kex_complete.rs - Auto-fix clippy warnings across all crates - All 153 tests pass
57 lines
1.1 KiB
Rust
57 lines
1.1 KiB
Rust
pub mod connection;
|
|
pub mod crc32c;
|
|
pub mod discovery;
|
|
pub mod login;
|
|
pub mod pdu;
|
|
pub mod scsi;
|
|
pub mod tools;
|
|
|
|
pub use connection::IscsiConnection;
|
|
pub use pdu::IscsiPdu;
|
|
pub use scsi::ScsiCommand;
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum Error {
|
|
#[error("IO error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
|
|
#[error("Protocol error: {0}")]
|
|
Protocol(String),
|
|
|
|
#[error("SCSI error: {0}")]
|
|
Scsi(String),
|
|
|
|
#[error("Connection error: {0}")]
|
|
Connection(String),
|
|
|
|
#[error("PDU parse error: {0}")]
|
|
PduParse(String),
|
|
}
|
|
|
|
/// iSCSI Initiator main entry point
|
|
pub struct Initiator {
|
|
connections: Vec<connection::IscsiConnection>,
|
|
}
|
|
|
|
impl Default for Initiator {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|
|
|
|
impl Initiator {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
connections: Vec::new(),
|
|
}
|
|
}
|
|
|
|
pub async fn connect(&mut self, addr: &str) -> Result<()> {
|
|
let conn = connection::IscsiConnection::connect(addr).await?;
|
|
self.connections.push(conn);
|
|
Ok(())
|
|
}
|
|
}
|