Skip to content

calternal_notes_core::rename

Pure title-retitle planning. The host applies these byte edits and performs the journalled write-new, verify, delete-old sequence through calternal-fs.

Source: crates/calternal-notes-core/src/rename.rs

pub struct ByteEdit

No doc comment.

Fields

  • pub range: Range<usize>
  • pub replacement: String

Implements: Debug, Clone, PartialEq, Eq

Source: crates/calternal-notes-core/src/rename.rs:25

pub struct NoteInput

No doc comment.

Fields

  • pub path: String
  • pub content: String

Implements: Debug, Clone, PartialEq, Eq

Source: crates/calternal-notes-core/src/rename.rs:19

pub struct ReferrerEdits

No doc comment.

Fields

  • pub path: String
  • pub edits: Vec<ByteEdit>

Implements: Debug, Clone, PartialEq, Eq

Source: crates/calternal-notes-core/src/rename.rs:31

pub struct RenamePlan

No doc comment.

Fields

  • pub old_path: String
  • pub new_path: String
  • pub new_content: String: Updated Note bytes. Hosts write this to the new path before removing old.
  • pub referrers: Vec<ReferrerEdits>: Exact destination-only changes for every referrer that points to this Note.
  • pub label: String: The title written as the label of rewritten wikilinks. With rewrite_referrer it rebuilds one referrer’s edits on newer text.

Implements: Debug, Clone, PartialEq, Eq

Source: crates/calternal-notes-core/src/rename.rs:37

pub fn apply_byte_edits(text: &str, edits: &[ByteEdit]) -> Result<String, String>

Apply a non-overlapping byte-edit list from right to left.

Source: crates/calternal-notes-core/src/rename.rs:316

pub fn plan_move(
note: &NoteInput,
new_path: &str,
referrers: &[NoteInput],
) -> Result<RenamePlan, String>

Plan a folder move with the same link rewrite rules as a retitle.

Source: crates/calternal-notes-core/src/rename.rs:104

pub fn plan_rename(
note: &NoteInput,
new_title: &str,
referrers: &[NoteInput],
) -> Result<RenamePlan, String>

Build a title retitle plan without reading or writing a filesystem.

referrers is the host’s already-resolved backlink set. The caller discovers those Notes through its index, then applies the returned byte edits under calternal-fs; this pure planner does not try to enumerate vault files.

Source: crates/calternal-notes-core/src/rename.rs:54

pub fn rewrite_referrer(
referrer: &NoteInput,
old_path: &str,
new_path: &str,
label: &str,
) -> Result<String, String>

Rewrite one referrer’s links to a moved or retitled Note on the referrer’s current text, with the same rules as the plan. A host uses it when the referrer changed after the plan was made (#98): writing the planned bytes then would drop that change. label is RenamePlan::label.

Source: crates/calternal-notes-core/src/rename.rs:155