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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileRef
impl<'de> Deserialize<'de> for FileRef
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for FileRef
Source§impl From<&FileRef> for QueryParam
impl From<&FileRef> for QueryParam
Source§fn from(value: &FileRef) -> QueryParam
fn from(value: &FileRef) -> QueryParam
Source§impl From<FileRef> for QueryParam
impl From<FileRef> for QueryParam
Source§fn from(value: FileRef) -> QueryParam
fn from(value: FileRef) -> QueryParam
Source§impl Serialize for FileRef
impl Serialize for FileRef
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for FileRef
Auto Trait Implementations§
impl Freeze for FileRef
impl RefUnwindSafe for FileRef
impl Send for FileRef
impl Sync for FileRef
impl Unpin for FileRef
impl UnsafeUnpin for FileRef
impl UnwindSafe for FileRef
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.