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.
Contains all metadata needed to locate and serve the file. The server stores this as a JSON string inside FILE-typed columns.
§JSON example
{
"id": "1234567890123456789",
"sub": "f0001",
"name": "document.pdf",
"size": 1048576,
"mime": "application/pdf",
"sha256": "abc123..."
}Fields§
§id: StringUnique file identifier (Snowflake ID).
sub: StringSubfolder name (e.g., "f0001", "f0002").
name: StringOriginal filename (preserved for display/download).
size: u64File size in bytes.
mime: StringMIME type (e.g., "image/png", "application/pdf").
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 from_json(json: &str) -> Option<FileRef>
pub fn from_json(json: &str) -> Option<FileRef>
Parse a FileRef from a raw JSON string (as stored in FILE columns).
Sourcepub fn from_json_value(value: &Value) -> Option<FileRef>
pub fn from_json_value(value: &Value) -> Option<FileRef>
Try to extract a FileRef from a serde_json::Value.
Handles both:
- A JSON string (the value is parsed as JSON)
- A JSON object (deserialized directly)
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.
{base_url}/v1/files/{namespace}/{table}/{sub}/{stored_name}Sourcepub fn relative_url(&self, namespace: &str, table: &str) -> String
pub fn relative_url(&self, namespace: &str, table: &str) -> String
Relative HTTP path (no host) for this file.
/v1/files/{namespace}/{table}/{sub}/{stored_name}Sourcepub fn stored_name(&self) -> String
pub fn stored_name(&self) -> String
Stored filename on disk.
Format: {id}-{sanitized_name}.{ext} or {id}.{ext} when the
original name contains only non-ASCII characters.
Sourcepub fn relative_path(&self) -> String
pub fn relative_path(&self) -> String
Relative path within the table folder.
- User tables:
{sub}/{stored_name} - Shared tables with shard:
shard-{n}/{sub}/{stored_name}
Sourcepub fn type_description(&self) -> String
pub fn type_description(&self) -> String
Human-readable file type description.
Examples: "Image", "Video", "PDF Document", "PNG File".
Sourcepub fn format_size(&self) -> String
pub fn format_size(&self) -> String
Format file size in human-readable units.
Examples: "0 B", "256 KB", "1.5 MB", "3.2 GB".
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 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.