Skip to main content

ReadOnlyResource

Trait ReadOnlyResource 

Source
pub trait ReadOnlyResource: RestResource { }
Expand description

A marker trait for REST resources that only support read operations.

Resources implementing this trait only support GET requests (find, all, count) and do not have Create, Update, or Delete operations. This serves as compile-time documentation of the resource’s capabilities and can be used for blanket implementations that restrict certain behaviors.

§Resources with this trait

The following Shopify resources are read-only:

  • Event - Store events (read-only audit log)
  • Policy - Store legal policies
  • Location - Store locations
  • Currency - Enabled currencies
  • User - Store staff users
  • AccessScope - App access scopes

§Example

use shopify_sdk::rest::{RestResource, ReadOnlyResource};

// Location only supports GET operations
impl RestResource for Location {
    const PATHS: &'static [ResourcePath] = &[
        ResourcePath::new(HttpMethod::Get, ResourceOperation::Find, &["id"], "locations/{id}"),
        ResourcePath::new(HttpMethod::Get, ResourceOperation::All, &[], "locations"),
        ResourcePath::new(HttpMethod::Get, ResourceOperation::Count, &[], "locations/count"),
        // No Create, Update, or Delete paths
    ];
    // ...
}

// Mark as read-only
impl ReadOnlyResource for Location {}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§