Skip to content

calternal_plugin_notes::canvas_assets

Home asset preparation for Canvas saves and exports (#989, DESIGN §60). The Files adapter owns identity, authorization and quota. Durable assets precede the Canvas compare-and-swap: interruption keeps the old Canvas intact, or leaves a new Canvas whose assets all exist. Content-derived names make a retry reuse completed assets instead of duplicating them.

Source: crates/plugins/notes/src/canvas_assets.rs

pub struct CanvasAsset

Files returns bounded bytes only after checking the current item identity.

Fields

  • pub bytes: Vec<u8>
  • pub mime: String

Source: crates/plugins/notes/src/canvas_assets.rs:13

pub trait CanvasAssets: Send + Sync

Break the Notes/Files dependency cycle without a second filesystem writer. Save is called only after a real event and the Note’s If-Match check.

fn install<'a>(
&'a self,
owner: &'a str,
path: &'a RelPath,
asset: &'a CanvasAsset,
namespace: &'a tokio::sync::MutexGuard<'_, ()>,
) -> Pin<Box<dyn Future<Output = std::result::Result<String, String>> + Send + 'a>>;

Install one verified asset without replacing any existing file. The writer holds this namespace guard through the final Canvas commit.

fn read<'a>(
&'a self,
viewer: &'a str,
canvas_path: &'a str,
reference: &'a serde_json::Value,
) -> Pin<Box<dyn Future<Output = std::result::Result<CanvasAsset, String>> + Send + 'a>>;

Resolve the ID first; a failed identity never falls back to a name.

Source: crates/plugins/notes/src/canvas_assets.rs:20

pub fn set_canvas_assets(adapter: Arc<dyn CanvasAssets>)

Install the one Files adapter at server startup, before routes accept work.

Source: crates/plugins/notes/src/canvas_assets.rs:42