openserve 2.0.3

A modern, high-performance, AI-enhanced file server built in Rust
Documentation
//! File-related data models.

use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};

/// Represents a file in the system.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct File {
    /// Name of the file
    pub name: String,
    /// Full path to the file
    pub path: String,
    /// Size of the file in bytes
    pub size: u64,
    /// Last modified timestamp
    pub modified: DateTime<Utc>,
    /// MIME type of the file
    pub mime_type: String,
    /// Whether the file is detected as text
    pub is_text: bool,
}

/// Represents a directory in the system.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Directory {
    /// Name of the directory
    pub name: String,
    /// Full path to the directory
    pub path: String,
    /// Last modified timestamp
    pub modified: DateTime<Utc>,
    /// Directory entries (files and subdirectories)
    pub entries: Vec<crate::services::file::DirectoryEntry>,
}

/// Represents metadata for a file.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileMetadata {
    /// Full path to the file
    pub path: String,
    /// Size of the file in bytes
    pub size: u64,
    /// Last modified timestamp
    pub modified: DateTime<Utc>,
    /// Creation timestamp
    pub created: Option<DateTime<Utc>>,
    /// Whether this is a directory
    pub is_dir: bool,
    /// MIME type of the file
    pub mime_type: String,
}

/// Response for a successful file upload.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UploadResponse {
    /// Path where the file was uploaded
    pub path: String,
    /// Size of the uploaded file in bytes
    pub size: u64,
    /// Success message
    pub message: String,
}