pub(super) struct StructureEditor<'c> {
doc: CourseStructure,
labels: Labels,
removed: HashMap<Uuid, usize>,
pub(super) ids: CreatedIdLog<'c>,
pub(super) warnings: Vec<Warning>,
paths: PathRequests,
new_pages: HashMap<Uuid, Vec<GutenbergBlock>>,
page_copies: Vec<PageCopy>,
page_pairings: BTreeMap<Uuid, Uuid>,
front_page: Option<Uuid>,
course_is_live: bool,
}Fields§
§doc: CourseStructure§labels: Labels§removed: HashMap<Uuid, usize>§ids: CreatedIdLog<'c>§warnings: Vec<Warning>§paths: PathRequests§new_pages: HashMap<Uuid, Vec<GutenbergBlock>>§page_copies: Vec<PageCopy>§page_pairings: BTreeMap<Uuid, Uuid>§front_page: Option<Uuid>The course front page, /, which stays first in /course/pages with its path.
course_is_live: boolImplementations§
Source§impl<'c> StructureEditor<'c>
impl<'c> StructureEditor<'c>
pub(super) fn new( doc: &CourseStructure, ops: &[Op], course_is_live: bool, ids: &'c dyn IdGenerator, ) -> Self
pub(super) fn apply_op(&mut self, op: &Op) -> Result<(), EditError>
fn require(&self, id: Uuid) -> Result<Loc, EditError>
fn not_found(&self, id: Uuid) -> EditError
fn address(&self, path: &str) -> Result<Address, EditError>
fn list_ids(&self, list: ListRef) -> Vec<Uuid>
fn take(&mut self, list: ListRef, start: usize, end: usize) -> Vec<Entity>
fn put( &mut self, list: ListRef, index: usize, entities: Vec<Entity>, ) -> Result<(), EditError>
fn anchor( &self, address: &Address, position: Option<Position>, ) -> Result<Anchor<ListRef>, EditError>
Sourcefn resolve_anchor(
&self,
anchor: Anchor<ListRef>,
kind: Kind,
) -> Result<(ListRef, usize), EditError>
fn resolve_anchor( &self, anchor: Anchor<ListRef>, kind: Kind, ) -> Result<(ListRef, usize), EditError>
(list, index) for an anchor in the current tree, checking the pinned positions.
Sourcefn pinned_first(&self, list: ListRef) -> Option<(EditErrorCode, Uuid)>
fn pinned_first(&self, list: ListRef) -> Option<(EditErrorCode, Uuid)>
What list keeps first, with the error code for disturbing it: the course front page in
/course/pages and the default module in /course/modules.
fn range( &self, from: Uuid, through: Option<Uuid>, ) -> Result<(Loc, usize), EditError>
fn sibling_paths(&self, list: ListRef) -> Vec<String>
fn check_not_pinned( &self, list: ListRef, start: usize, action: &str, ) -> Result<(), EditError>
fn new_entities( &mut self, kind: Kind, value: &Value, ) -> Result<Vec<Entity>, EditError>
fn new_entity(&mut self, kind: Kind, value: &Value) -> Result<Entity, EditError>
fn new_page( &mut self, object: &Map<String, Value>, ) -> Result<StructurePage, EditError>
Sourcefn materialize_blocks(
&mut self,
page_id: Uuid,
value: &Value,
) -> Result<Vec<GutenbergBlock>, EditError>
fn materialize_blocks( &mut self, page_id: Uuid, value: &Value, ) -> Result<Vec<GutenbergBlock>, EditError>
Builds a new page’s blocks with the page tool’s rules.
fn add( &mut self, path: &str, value: &Value, position: Option<Position>, ) -> Result<(), EditError>
Sourcefn entity_at(&self, path: &str, message: &str) -> Result<Uuid, EditError>
fn entity_at(&self, path: &str, message: &str) -> Result<Uuid, EditError>
The entity path names; any other address fails with message.
fn remove(&mut self, path: &str, through: Option<&str>) -> Result<(), EditError>
fn replace(&mut self, path: &str, value: &Value) -> Result<(), EditError>
fn field_value(&self, id: Uuid, kind: Kind, field: &str) -> Option<Value>
Sourcefn set_field(
&mut self,
id: Uuid,
field: &str,
value: Value,
) -> Result<(), EditError>
fn set_field( &mut self, id: Uuid, field: &str, value: Value, ) -> Result<(), EditError>
Sets one editable field; Value::Null clears it. field passed check_field.
fn move_entities(&mut self, transfer: &Transfer) -> Result<(), EditError>
fn copy( &mut self, transfer: &Transfer, label: Option<&str>, ) -> Result<(), EditError>
fn copy_page(&mut self, source: &StructurePage) -> StructurePage
fn reorder(&mut self, path: &str, value: &Value) -> Result<(), EditError>
pub(super) fn finish( self, before: &CourseStructure, ) -> Result<StructureResult, EditError>
Sourcefn check_final_invariants(&self) -> Result<(), EditError>
fn check_final_invariants(&self) -> Result<(), EditError>
What every op keeps, checked once more on the result: the pinned first items, module names and chapter front pages.
Sourcefn renumber_chapters(
&mut self,
before: &CourseStructure,
) -> Vec<ChapterRenumber>
fn renumber_chapters( &mut self, before: &CourseStructure, ) -> Vec<ChapterRenumber>
Numbers the chapters 1, 2, … in order and lists the ones whose number changed from before.
Auto Trait Implementations§
impl<'c> Freeze for StructureEditor<'c>
impl<'c> !RefUnwindSafe for StructureEditor<'c>
impl<'c> Send for StructureEditor<'c>
impl<'c> Sync for StructureEditor<'c>
impl<'c> Unpin for StructureEditor<'c>
impl<'c> UnsafeUnpin for StructureEditor<'c>
impl<'c> !UnwindSafe for StructureEditor<'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
Mutably borrows from an owned value. Read more
§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>
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 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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
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>,
Applies the layer to a service and wraps it in [
Layered].§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more