1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Asset scan results and metrics
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use super::asset_types::AssetPriority;
/// A detected embedded asset
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetectedAsset {
/// Path to the embedded asset (relative to source file)
pub file_path: String,
/// Size in bytes
pub size_bytes: u64,
/// Type of asset
pub asset_type: super::asset_types::AssetType,
/// Where it was detected (file:line)
pub source_location: String,
/// How it was detected (include_bytes!, rustybuzz, etc.)
pub detection_method: String,
}
/// Complete scan results with all detected assets
#[derive(Debug, Serialize, Deserialize)]
pub struct ScanResults {
/// Total number of detected assets
pub total_assets: usize,
/// Total size of all assets in KB
pub total_size_kb: u64,
/// Total bundle size in KB
pub bundle_size_kb: u64,
/// Percentage of bundle occupied by assets
pub bundle_percentage: f64,
/// All detected assets
pub assets: Vec<DetectedAsset>,
/// Assets grouped by priority level
pub assets_by_priority: HashMap<AssetPriority, Vec<DetectedAsset>>,
/// Estimated savings from externalization
pub estimated_savings: EstimatedSavings,
}
/// Estimated savings from externalizing assets
#[derive(Debug, Serialize, Deserialize)]
pub struct EstimatedSavings {
/// Savings from externalizing critical priority assets only (KB)
pub critical_only_kb: u64,
/// Savings from externalizing high and critical priority assets (KB)
pub high_and_critical_kb: u64,
/// Savings from externalizing all assets (KB)
pub all_assets_kb: u64,
/// Savings from critical assets as percentage of bundle
pub critical_only_percent: f64,
/// Savings from high+critical assets as percentage of bundle
pub high_and_critical_percent: f64,
/// Savings from all assets as percentage of bundle
pub all_assets_percent: f64,
}