struct Editor<'c> {
pages: Vec<PageDocument>,
labels: Labels,
removed: HashMap<Uuid, usize>,
ids: CreatedIdLog<'c>,
warnings: Vec<Warning>,
moves: Vec<BlockPageMove>,
exercise_copies: Vec<ExerciseCopy>,
can_reach_other_pages: bool,
}Fields§
§pages: Vec<PageDocument>The edited page first, then the to_pages.
labels: Labels§removed: HashMap<Uuid, usize>§ids: CreatedIdLog<'c>§warnings: Vec<Warning>§moves: Vec<BlockPageMove>§exercise_copies: Vec<ExerciseCopy>§can_reach_other_pages: boolWhether the current op may find blocks on the to_pages besides the edited page.
Implementations§
Source§impl Editor<'_>
impl Editor<'_>
Sourcepub(super) fn locate(&self, id: Uuid) -> Option<Loc>
pub(super) fn locate(&self, id: Uuid) -> Option<Loc>
Where the block is: on the page being edited, or for move and copy also on a to_page.
pub(super) fn require(&self, id: Uuid) -> Result<Loc, EditError>
pub(super) fn not_found(&self, id: Uuid) -> EditError
Sourcepub(super) fn address(
&self,
path: &str,
root_page: usize,
) -> Result<Address, EditError>
pub(super) fn address( &self, path: &str, root_page: usize, ) -> Result<Address, EditError>
Parses a page path. root_page is what "" means: the edited page, or to_page.
pub(super) fn anchor( &self, address: &Address, position: Option<Position>, ) -> Result<Anchor<ListRef>, EditError>
pub(super) fn anchor_page( &self, anchor: Anchor<ListRef>, ) -> Result<usize, EditError>
Sourcepub(super) fn resolve_anchor(
&self,
anchor: Anchor<ListRef>,
) -> Result<(usize, Vec<usize>, usize), EditError>
pub(super) fn resolve_anchor( &self, anchor: Anchor<ListRef>, ) -> Result<(usize, Vec<usize>, usize), EditError>
(page, parent path, insertion index) for an anchor in the current tree.
Sourcepub(super) fn list_parent_path(
&self,
list: ListRef,
) -> Result<Vec<usize>, EditError>
pub(super) fn list_parent_path( &self, list: ListRef, ) -> Result<Vec<usize>, EditError>
The index path of the block whose children list is; empty for a page’s top level.
pub(super) fn range( &self, first: Uuid, through: Option<Uuid>, ) -> Result<Range, EditError>
pub(super) fn range_blocks( &self, range: &Range, ) -> Result<&[GutenbergBlock], EditError>
Source§impl Editor<'_>
impl Editor<'_>
Sourcepub(super) fn replace_list(
&mut self,
list: ListRef,
entries: Vec<ListEntry>,
) -> Result<(), EditError>
pub(super) fn replace_list( &mut self, list: ListRef, entries: Vec<ListEntry>, ) -> Result<(), EditError>
Replaces the children of list with entries. Existing blocks they name move into the list;
every block the list held must be named, so nothing is deleted by omission.
fn build_entries( &mut self, entries: Vec<ListEntry>, existing: &HashMap<Uuid, GutenbergBlock>, ) -> Result<Vec<GutenbergBlock>, EditError>
Sourcepub(super) fn build_entry(
&mut self,
entry: ListEntry,
existing: &HashMap<Uuid, GutenbergBlock>,
) -> Result<GutenbergBlock, EditError>
pub(super) fn build_entry( &mut self, entry: ListEntry, existing: &HashMap<Uuid, GutenbergBlock>, ) -> Result<GutenbergBlock, EditError>
The block entry describes; existing holds the blocks its stubs and ids name.
Source§impl<'c> Editor<'c>
impl<'c> Editor<'c>
fn new( page: PageDocument, load_page: &dyn Fn(Uuid) -> Option<PageDocument>, ops: &[Op], ids: &'c dyn IdGenerator, ) -> Result<Self, EditError>
fn finish(self) -> PageContentResult
fn apply_op(&mut self, op: &Op) -> Result<(), EditError>
fn block(&self, loc: &Loc) -> Result<&GutenbergBlock, EditError>
fn block_mut(&mut self, loc: &Loc) -> Result<&mut GutenbergBlock, EditError>
fn page_id(&self, page: usize) -> Uuid
fn page_index(&self, page_id: Uuid) -> usize
fn siblings(&self, page: usize, parent_path: &[usize]) -> Vec<String>
Sourcefn check_not_in_exercise(
&self,
loc: &Loc,
include_self: bool,
action: &str,
) -> Result<(), EditError>
fn check_not_in_exercise( &self, loc: &Loc, include_self: bool, action: &str, ) -> Result<(), EditError>
Fails when loc is an exercise block’s inside, or (with include_self) the exercise block.
fn insert( &mut self, anchor: Anchor<ListRef>, new_blocks: Vec<GutenbergBlock>, ) -> Result<(), EditError>
fn detach(&mut self, range: &Range) -> Result<Vec<GutenbergBlock>, EditError>
fn mark_removed(&mut self, removed: &[GutenbergBlock])
Sourcefn block_at(
&self,
path: &str,
root_page: usize,
message: &str,
) -> Result<Uuid, EditError>
fn block_at( &self, path: &str, root_page: usize, message: &str, ) -> Result<Uuid, EditError>
The block path names; any other address fails with message.
fn through(&self, through: Option<&str>) -> Result<Option<Uuid>, EditError>
Sourcefn new_block(&mut self, value: &Value) -> Result<GutenbergBlock, EditError>
fn new_block(&mut self, value: &Value) -> Result<GutenbergBlock, EditError>
A new block from an add or wrap value.
fn add( &mut self, path: &str, value: &Value, position: Option<Position>, ) -> Result<(), EditError>
fn remove(&mut self, path: &str, through: Option<&str>) -> Result<(), EditError>
fn replace(&mut self, path: &str, value: &Value) -> Result<(), EditError>
fn set_attribute( &mut self, id: Uuid, pointer: &str, value: Value, mode: PointerWrite, ) -> Result<(), EditError>
fn replace_block(&mut self, id: Uuid, value: &Value) -> Result<(), EditError>
Sourcefn resolve_transfer(
&self,
transfer: &Transfer,
verb: &str,
) -> Result<(Range, usize, Anchor<ListRef>), EditError>
fn resolve_transfer( &self, transfer: &Transfer, verb: &str, ) -> Result<(Range, usize, Anchor<ListRef>), EditError>
The range a move or copy takes from the edited page, the index of the page it goes to,
and where there. verb names the op in errors.
Sourcefn check_exercises_stay_top_level(
&self,
range: &Range,
anchor: Anchor<ListRef>,
) -> Result<(), EditError>
fn check_exercises_stay_top_level( &self, range: &Range, anchor: Anchor<ListRef>, ) -> Result<(), EditError>
Fails when anchor would put an exercise block of range below the top level.
fn move_range(&mut self, transfer: &Transfer) -> Result<(), EditError>
fn copy_range( &mut self, transfer: &Transfer, label: Option<&str>, ) -> Result<(), EditError>
fn wrap( &mut self, path: &str, through: Option<&str>, value: &Value, label: Option<&str>, ) -> Result<(), EditError>
fn unwrap(&mut self, path: &str) -> Result<(), EditError>
fn split( &mut self, path: &str, at_text: &str, label: Option<&str>, ) -> Result<(), EditError>
fn merge(&mut self, path: &str, from: &str) -> Result<(), EditError>
fn check_invariants(&self) -> Result<(), EditError>
Auto Trait Implementations§
impl<'c> Freeze for Editor<'c>
impl<'c> !RefUnwindSafe for Editor<'c>
impl<'c> Send for Editor<'c>
impl<'c> Sync for Editor<'c>
impl<'c> Unpin for Editor<'c>
impl<'c> UnsafeUnpin for Editor<'c>
impl<'c> !UnwindSafe for Editor<'c>
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].