pub struct RileyCms { /* private fields */ }Expand description
Main entry point for riley_cms functionality.
RileyCms provides access to all CMS operations: listing posts and series,
retrieving individual content, managing assets, and cache control.
§Example
use riley_cms_core::{RileyCms, RileyCmsConfig, ListOptions};
let config: RileyCmsConfig = toml::from_str(r#"
[content]
repo_path = "/data/content"
[storage]
bucket = "my-assets"
public_url_base = "https://assets.example.com"
"#)?;
let riley_cms = RileyCms::from_config(config).await?;
let posts = riley_cms.list_posts(&ListOptions::default()).await?;Implementations§
Source§impl RileyCms
impl RileyCms
Sourcepub async fn from_config(config: RileyCmsConfig) -> Result<Self>
pub async fn from_config(config: RileyCmsConfig) -> Result<Self>
Create a new RileyCms instance from configuration.
This loads content from disk into an in-memory cache and initializes the S3 storage client.
§Errors
Returns an error if content cannot be loaded or S3 configuration is invalid.
Sourcepub async fn list_posts(
&self,
opts: &ListOptions,
) -> Result<ListResult<PostSummary>>
pub async fn list_posts( &self, opts: &ListOptions, ) -> Result<ListResult<PostSummary>>
List posts with filtering and pagination.
By default, only live posts (with goes_live_at in the past) are returned.
Use ListOptions to include drafts or scheduled posts.
Posts are sorted by goes_live_at descending (newest first).
Sourcepub async fn get_post(&self, slug: &str) -> Result<Option<Post>>
pub async fn get_post(&self, slug: &str) -> Result<Option<Post>>
Get a single post by its slug.
Returns None if no post with the given slug exists.
Note: This returns the post regardless of visibility status.
Sourcepub async fn list_series(
&self,
opts: &ListOptions,
) -> Result<ListResult<SeriesSummary>>
pub async fn list_series( &self, opts: &ListOptions, ) -> Result<ListResult<SeriesSummary>>
List series with filtering and pagination.
By default, only live series are returned.
Series are sorted by goes_live_at descending.
Sourcepub async fn get_series(&self, slug: &str) -> Result<Option<Series>>
pub async fn get_series(&self, slug: &str) -> Result<Option<Series>>
Get a single series by its slug, including all posts.
Posts within the series are sorted by their order field,
with alphabetical fallback for ties or missing values.
Sourcepub async fn validate_content(&self) -> Result<Vec<ValidationError>>
pub async fn validate_content(&self) -> Result<Vec<ValidationError>>
Validate content structure and return any errors.
Checks for common issues like empty titles, missing content, etc.
Sourcepub async fn list_assets(
&self,
opts: &AssetListOptions,
) -> Result<AssetListResult>
pub async fn list_assets( &self, opts: &AssetListOptions, ) -> Result<AssetListResult>
List assets in the S3/R2 storage bucket with pagination.
Uses cursor-based pagination via S3 continuation tokens. Defaults to 100 assets per page, capped at 1000.
Sourcepub async fn upload_asset(
&self,
path: &Path,
dest: Option<&str>,
) -> Result<Asset>
pub async fn upload_asset( &self, path: &Path, dest: Option<&str>, ) -> Result<Asset>
Upload a file to the storage bucket.
§Arguments
path- Local file path to uploaddest- Optional destination path in bucket (defaults to filename)
Sourcepub async fn refresh(&self) -> Result<()>
pub async fn refresh(&self) -> Result<()>
Refresh the content cache from disk.
Call this after content has been updated (e.g., after a git push) to reload the in-memory cache.
Sourcepub async fn content_etag(&self) -> String
pub async fn content_etag(&self) -> String
Get an ETag representing the current content state.
This is a hash of all content, suitable for HTTP caching headers. The ETag changes when any content is modified.
Sourcepub async fn fire_webhooks(&self)
pub async fn fire_webhooks(&self)
Fire webhooks after content update.
Each webhook is validated and sent atomically: DNS is resolved once, checked against private/internal IP ranges, and the connection is pinned to the validated IP (preventing DNS rebinding/TOCTOU attacks).
If a secret is configured in [webhooks], signs each request body with
HMAC-SHA256 and includes the hex signature in the X-Riley-Cms-Signature header.
Retries up to 3 times with exponential backoff on network errors or 5xx responses.
Sourcepub fn config(&self) -> &RileyCmsConfig
pub fn config(&self) -> &RileyCmsConfig
Get a reference to the config.
Auto Trait Implementations§
impl Freeze for RileyCms
impl !RefUnwindSafe for RileyCms
impl Send for RileyCms
impl Sync for RileyCms
impl Unpin for RileyCms
impl !UnwindSafe for RileyCms
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more