snap7-client 0.1.4

Async Rust client for Siemens S7 PLCs over ISO-on-TCP (S7Comm and S7CommPlus)
Documentation
use crate::proto::ProtoError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("protocol error: {0}")]
    Proto(#[from] ProtoError),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("PLC error: code={code:#06x} ({message})")]
    PlcError { code: u32, message: String },

    #[error("connection timeout after {0:?}")]
    Timeout(std::time::Duration),

    #[error("PDU negotiation failed")]
    NegotiationFailed,

    #[error("connection refused or PLC not responding")]
    ConnectionRefused,

    #[error("unexpected response PDU type")]
    UnexpectedResponse,
}

pub type Result<T> = std::result::Result<T, Error>;