-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from picture-pro/10-add-crate-docs-and-readme
10 add crate docs and readme
- Loading branch information
Showing
11 changed files
with
266 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,38 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The table name for the private artifact table. | ||
pub const PRIVATE_ARTIFACT_TABLE: &str = "private_artifact"; | ||
/// The table name for the public artifact table. | ||
pub const PUBLIC_ARTIFACT_TABLE: &str = "public_artifact"; | ||
|
||
/// The record ID for a private artifact. | ||
#[derive(Clone, Debug, Deserialize, Serialize, Copy)] | ||
#[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] | ||
#[cfg_attr(feature = "ssr", serde(from = "crate::ssr::UlidOrThing"))] | ||
pub struct PrivateArtifactRecordId(pub ulid::Ulid); | ||
|
||
/// A private artifact. | ||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct PrivateArtifact { | ||
/// The record ID. | ||
pub id: PrivateArtifactRecordId, | ||
/// The contents of the artifact (skipped by serde) | ||
#[serde(skip)] | ||
pub contents: Option<bytes::Bytes>, | ||
} | ||
|
||
/// The record ID for a public artifact. | ||
#[derive(Clone, Debug, Deserialize, Serialize, Copy)] | ||
#[cfg_attr(feature = "ssr", serde(from = "crate::conv::UlidOrThing"))] | ||
#[cfg_attr(feature = "ssr", serde(from = "crate::ssr::UlidOrThing"))] | ||
pub struct PublicArtifactRecordId(pub ulid::Ulid); | ||
|
||
/// A public artifact. | ||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct PublicArtifact { | ||
/// The record ID. | ||
pub id: PublicArtifactRecordId, | ||
/// The public URL to the artifact. | ||
pub url: String, | ||
#[serde(skip)] | ||
/// The contents of the artifact (skipped by serde) | ||
pub contents: Option<bytes::Bytes>, | ||
} | ||
|
||
#[cfg(feature = "ssr")] | ||
mod ssr { | ||
use surreal_id::NewId; | ||
use surrealdb::sql::Id; | ||
|
||
use super::*; | ||
|
||
impl NewId for PrivateArtifactRecordId { | ||
const TABLE: &'static str = PRIVATE_ARTIFACT_TABLE; | ||
|
||
fn from_inner_id<T: Into<Id>>(inner_id: T) -> Self { | ||
Self(inner_id.into().to_string().parse().unwrap()) | ||
} | ||
fn get_inner_string(&self) -> String { self.0.to_string() } | ||
} | ||
|
||
impl NewId for PublicArtifactRecordId { | ||
const TABLE: &'static str = PUBLIC_ARTIFACT_TABLE; | ||
|
||
fn from_inner_id<T: Into<Id>>(inner_id: T) -> Self { | ||
Self(inner_id.into().to_string().parse().unwrap()) | ||
} | ||
fn get_inner_string(&self) -> String { self.0.to_string() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.