smb 0.4.1

A Pure Rust SMB Client implementation
use std::sync::Arc;

use crate::dialects::DialectImpl;
use crate::packets::guid::Guid;
use crate::packets::smb2::*;
use binrw::prelude::*;

use super::ConnectionConfig;

/// Contains important information from the negotiation process,
/// to be used during connection operations.
#[derive(Debug)]
pub struct NegotiatedProperties {
    /// From the server's negotiation response.
    pub server_guid: Guid,

    /// From the server's negotiation response.
    pub caps: GlobalCapabilities,

    /// From the server's negotiation response.
    pub max_transact_size: u32,
    /// From the server's negotiation response.
    pub max_read_size: u32,
    /// From the server's negotiation response.
    pub max_write_size: u32,

    /// From the server's negotiation response.
    pub auth_buffer: Vec<u8>,

    /// Signing algorithm used for the connection, and specified by the server
    /// using negotiation context. This is irrelevant for dialects below 3.1.1,
    /// and if not specified, this property is not set, but the connection may still be
    /// signed using the default algorithm, as specified in the spec.
    pub signing_algo: Option<SigningAlgorithmId>,
    /// Encryption cipher used for the connection, and specified by the server
    /// using negotiation context. This is irrelevant for dialects below 3.1.1,
    /// and if not specified, this property is not set, but the connection may still be
    /// encrypted using the default cipher, as specified in the spec.
    pub encryption_cipher: Option<EncryptionCipher>,
    /// Compression capabilities used for the connection, and specified by the server
    /// using negotiation context.
    pub compression: Option<CompressionCaps>,

    /// The selected dialect revision for the connection.
    /// Use [ConnectionInfo::dialect] to get the implementation of the selected dialect.
    pub dialect_rev: Dialect,
}

/// This struct is initalized once a connection is established and negotiated.
/// It contains all the information about the connection.
#[derive(Debug)]
pub struct ConnectionInfo {
    /// Contains negotiated properties of the connection.
    pub negotiation: NegotiatedProperties,
    /// Contains the implementation of the selected dialect.
    pub dialect: Arc<DialectImpl>,
    /// Contains the configuration of the connection, as specified by the user when the connection was established.
    pub config: ConnectionConfig,
}