chore: initial sanitized public snapshot
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
//! Session models shared by protocol-aware download workflows.
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
use crate::{
|
||||
auth::AuthCredentialModel,
|
||||
http::{Cookie, HttpHeader, ProxyConfig, RetryStrategy, TlsConfig},
|
||||
};
|
||||
|
||||
/// Coarse lifecycle state for a transport session.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum SessionState {
|
||||
/// Session exists but has not started work.
|
||||
Idle,
|
||||
/// Session is establishing a connection.
|
||||
Connecting,
|
||||
/// Session is actively transferring data.
|
||||
Active,
|
||||
/// Session is paused.
|
||||
Paused,
|
||||
/// Session completed successfully.
|
||||
Completed,
|
||||
/// Session ended with a failure.
|
||||
Failed,
|
||||
}
|
||||
|
||||
/// Scope at which a session model applies.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum SessionScope {
|
||||
/// Global client-wide scope.
|
||||
Global,
|
||||
/// Protocol-family scope.
|
||||
Protocol,
|
||||
/// Single transfer scope.
|
||||
Transfer,
|
||||
}
|
||||
|
||||
/// Operational limits attached to a session.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct SessionLimits {
|
||||
/// Maximum simultaneous connections.
|
||||
pub max_connections: u16,
|
||||
/// Maximum parallel downloads across the session.
|
||||
pub max_parallel_downloads: u16,
|
||||
/// Delay before reconnecting after a failure, in milliseconds.
|
||||
pub reconnect_delay_ms: u64,
|
||||
}
|
||||
|
||||
/// Preferred protocol ordering within a session.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SessionTransportPreference {
|
||||
/// Protocol identifier string.
|
||||
pub protocol: String,
|
||||
/// Smaller numbers indicate higher preference.
|
||||
pub priority: u8,
|
||||
/// Whether this protocol is enabled.
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
/// End-user session configuration and live state.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SessionModel {
|
||||
/// Stable session identifier.
|
||||
pub session_id: String,
|
||||
/// Current lifecycle state.
|
||||
pub state: SessionState,
|
||||
/// Scope for this session.
|
||||
pub scope: SessionScope,
|
||||
/// Optional user-agent string.
|
||||
pub user_agent: Option<String>,
|
||||
/// Default headers applied to requests.
|
||||
pub headers: Vec<HttpHeader>,
|
||||
/// Persisted or injected cookies.
|
||||
pub cookies: Vec<Cookie>,
|
||||
/// Optional authentication material.
|
||||
pub auth: Option<AuthCredentialModel>,
|
||||
/// Optional proxy configuration.
|
||||
pub proxy: Option<ProxyConfig>,
|
||||
/// Optional TLS configuration.
|
||||
pub tls: Option<TlsConfig>,
|
||||
/// Retry behavior for requests in the session.
|
||||
pub retry: RetryStrategy,
|
||||
/// Operational session limits.
|
||||
pub limits: SessionLimits,
|
||||
/// Ordered transport preferences.
|
||||
pub preferred_transports: Vec<SessionTransportPreference>,
|
||||
}
|
||||
|
||||
/// Remote server descriptor associated with a session.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct ServerModel {
|
||||
/// Human-readable server name.
|
||||
pub name: String,
|
||||
/// Host name or IP address.
|
||||
pub host: String,
|
||||
/// Listen port.
|
||||
pub port: u16,
|
||||
/// Whether TLS is enabled.
|
||||
pub tls_enabled: bool,
|
||||
}
|
||||
|
||||
/// Client descriptor that can be associated with server sessions.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct ClientModel {
|
||||
/// Stable client identifier.
|
||||
pub client_id: String,
|
||||
/// Preferred session id when one exists.
|
||||
pub preferred_session: Option<String>,
|
||||
/// Optional server currently associated with the client.
|
||||
pub server: Option<ServerModel>,
|
||||
}
|
||||
|
||||
/// Collection of sessions known for a given server.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct ServerSessionModel {
|
||||
/// Server whose sessions are being reported.
|
||||
pub server: ServerModel,
|
||||
/// Sessions currently associated with the server.
|
||||
pub sessions: Vec<SessionModel>,
|
||||
}
|
||||
Reference in New Issue
Block a user