pub struct ServerState {
pub config: RwLock<EngineConfig>,
pub pending_transfers: RwLock<HashMap<String, PendingTransfer>>,
pub approved_tokens: RwLock<HashMap<String, String>>,
pub rejected_transfers: RwLock<HashMap<String, String>>,
pub cancelled_transfers: RwLock<HashSet<String>>,
pub received_files: RwLock<HashMap<String, HashSet<String>>>,
pub transfer_bytes: RwLock<HashMap<String, u64>>,
pub transfer_start_times: RwLock<HashMap<String, Instant>>,
/* private fields */
}Expand description
Server state shared across handlers
Fields§
§config: RwLock<EngineConfig>Engine configuration
pending_transfers: RwLock<HashMap<String, PendingTransfer>>Pending transfers awaiting user approval
approved_tokens: RwLock<HashMap<String, String>>Approved transfer tokens (transfer_id -> token)
rejected_transfers: RwLock<HashMap<String, String>>Rejected transfers (transfer_id -> reason)
cancelled_transfers: RwLock<HashSet<String>>Cancelled transfers (transfer_id)
received_files: RwLock<HashMap<String, HashSet<String>>>Received files per transfer (transfer_id -> set of file_ids)
transfer_bytes: RwLock<HashMap<String, u64>>Bytes received per transfer (transfer_id -> total bytes received so far)
transfer_start_times: RwLock<HashMap<String, Instant>>Transfer start times (transfer_id -> start instant)
Implementations§
Source§impl ServerState
impl ServerState
Sourcepub fn new(config: EngineConfig, event_handler: Arc<dyn EventHandler>) -> Self
pub fn new(config: EngineConfig, event_handler: Arc<dyn EventHandler>) -> Self
Create a new server state with the given configuration and event handler
Sourcepub fn new_with_history(
config: EngineConfig,
event_handler: Arc<dyn EventHandler>,
history: Arc<dyn HistoryPersistence>,
) -> Self
pub fn new_with_history( config: EngineConfig, event_handler: Arc<dyn EventHandler>, history: Arc<dyn HistoryPersistence>, ) -> Self
Create a new server state with history persistence
Sourcepub async fn accept_transfer(&self, transfer_id: &str) -> EngineResult<String>
pub async fn accept_transfer(&self, transfer_id: &str) -> EngineResult<String>
Accept a pending transfer
Sourcepub async fn reject_transfer(&self, transfer_id: &str) -> EngineResult<()>
pub async fn reject_transfer(&self, transfer_id: &str) -> EngineResult<()>
Reject a pending transfer
Sourcepub async fn cancel_transfer(&self, transfer_id: &str) -> EngineResult<()>
pub async fn cancel_transfer(&self, transfer_id: &str) -> EngineResult<()>
Cancel an in-progress transfer
This will cause subsequent chunk uploads to be rejected.
Sourcepub async fn is_transfer_cancelled(&self, transfer_id: &str) -> bool
pub async fn is_transfer_cancelled(&self, transfer_id: &str) -> bool
Check if a transfer has been cancelled
Sourcepub async fn get_pending_transfers(&self) -> Vec<PendingTransfer>
pub async fn get_pending_transfers(&self) -> Vec<PendingTransfer>
Get all pending transfers
Sourcepub async fn update_config(&self, config: EngineConfig)
pub async fn update_config(&self, config: EngineConfig)
Update the configuration
Auto Trait Implementations§
impl !Freeze for ServerState
impl !RefUnwindSafe for ServerState
impl Send for ServerState
impl Sync for ServerState
impl Unpin for ServerState
impl !UnwindSafe for ServerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more