RileyCms

Struct RileyCms 

Source
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

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 upload
  • dest - Optional destination path in bucket (defaults to filename)
Source

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.

Source

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.

Source

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.

Source

pub fn config(&self) -> &RileyCmsConfig

Get a reference to the config.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more