pub struct FileRef {
pub id: String,
pub sub: String,
pub name: String,
pub size: u64,
pub mime: String,
pub sha256: String,
pub shard: Option<u32>,
}Expand description
File reference stored as JSON in FILE columns.
Fields§
§id: StringUnique file identifier.
sub: StringSubfolder name, for example "f0001".
name: StringOriginal filename preserved for display and download.
size: u64File size in bytes.
mime: StringMIME type.
sha256: StringSHA-256 hash of file content, hex encoded.
shard: Option<u32>Optional shard ID for shared tables.
Implementations§
Source§impl FileRef
impl FileRef
Sourcepub fn new(
id: String,
subfolder: String,
name: String,
size: u64,
mime: String,
sha256: String,
) -> FileRef
pub fn new( id: String, subfolder: String, name: String, size: u64, mime: String, sha256: String, ) -> FileRef
Create a new file reference.
Sourcepub fn with_shard(
id: String,
subfolder: String,
name: String,
size: u64,
mime: String,
sha256: String,
shard: u32,
) -> FileRef
pub fn with_shard( id: String, subfolder: String, name: String, size: u64, mime: String, sha256: String, shard: u32, ) -> FileRef
Create a new file reference with shared-table shard metadata.
Sourcepub fn partial(id: String, subfolder: String) -> FileRef
pub fn partial(id: String, subfolder: String) -> FileRef
Create a partial file reference for download path validation.
Sourcepub fn try_from_json(json: &str) -> Result<FileRef, Error>
pub fn try_from_json(json: &str) -> Result<FileRef, Error>
Parse a file reference from a raw JSON string, preserving serde errors.
Sourcepub fn from_json_value(value: &Value) -> Option<FileRef>
pub fn from_json_value(value: &Value) -> Option<FileRef>
Try to extract a file reference from a JSON value.
Sourcepub fn download_url(
&self,
base_url: &str,
namespace: &str,
table: &str,
) -> String
pub fn download_url( &self, base_url: &str, namespace: &str, table: &str, ) -> String
Full download URL for this file.
Sourcepub fn relative_url(&self, namespace: &str, table: &str) -> String
pub fn relative_url(&self, namespace: &str, table: &str) -> String
Relative HTTP path for this file.
Sourcepub fn stored_name(&self) -> String
pub fn stored_name(&self) -> String
Stored filename on disk.
Sourcepub fn is_valid_subfolder(subfolder: &str) -> bool
pub fn is_valid_subfolder(subfolder: &str) -> bool
Validate subfolder name format, for example "f0001".
Sourcepub fn relative_path(&self) -> String
pub fn relative_path(&self) -> String
Relative path within the table folder.
Sourcepub fn type_description(&self) -> String
pub fn type_description(&self) -> String
Human-readable file type description.
Sourcepub fn format_size(&self) -> String
pub fn format_size(&self) -> String
Format file size in human-readable units.
Sourcepub fn validate_mime_type(&self, allowed_mimes: &[String]) -> bool
pub fn validate_mime_type(&self, allowed_mimes: &[String]) -> bool
Validate MIME type against an allowlist.