fileloft-core 0.3.0

Framework-agnostic core for the tus.io resumable upload protocol
Documentation
use crate::{error::TusError, info::UploadId};

/// A held lock. Dropping does NOT release it — call `release()` explicitly to
/// allow async cleanup. Implementations should panic or log on drop if not released.
#[trait_variant::make(SendLock: Send)]
pub trait Lock {
    async fn release(self) -> Result<(), TusError>;
}

/// Concurrency guard — one exclusive lock per upload ID.
///
/// The `Send`-safe variant `SendLocker` is generated by `trait_variant`.
#[trait_variant::make(SendLocker: Send)]
pub trait Locker {
    type LockType: SendLock;

    /// Acquire an exclusive lock for the given upload ID.
    /// Should block (respecting a timeout) rather than fail immediately.
    async fn acquire(&self, id: &UploadId) -> Result<Self::LockType, TusError>;
}