Skip to main content

PageSnapshot

Struct PageSnapshot 

Source
pub struct PageSnapshot {
    pub id: Uuid,
    pub course_id: Uuid,
    pub chapter_id: Option<Uuid>,
    pub url_path: String,
    pub title: String,
    pub hidden: bool,
    pub order_number: i32,
    pub content: Arc<Vec<GutenbergBlock>>,
    pub exercises: Vec<CmsPageExercise>,
    pub exercise_slides: Vec<CmsPageExerciseSlide>,
    pub exercise_tasks: Vec<CmsPageExerciseTask>,
    pub joins_page_language_group_id: Option<Uuid>,
}
Expand description

A course page: its metadata, its stored blocks and its exercises, in the shape the CMS page save takes. Exercise blocks in content are stored stripped to their id, as the CMS stores them; the exercises themselves are in exercises, exercise_slides and exercise_tasks.

Fields§

§id: Uuid§course_id: Uuid§chapter_id: Option<Uuid>

None for top-level pages.

§url_path: String§title: String§hidden: bool§order_number: i32

Position among the pages of the same chapter (or the top-level pages). 0 is reserved for a chapter’s front page.

§content: Arc<Vec<GutenbergBlock>>

Shared with the page records made from the snapshot.

§exercises: Vec<CmsPageExercise>§exercise_slides: Vec<CmsPageExerciseSlide>§exercise_tasks: Vec<CmsPageExerciseTask>§joins_page_language_group_id: Option<Uuid>

For a page publishing creates: the page language group of its versions in the course’s other languages that it joins. None for every other page, whatever group it is in.

Implementations§

Source§

impl PageSnapshot

Source

pub fn from_record_and_bundles( course_id: Uuid, record: &PageRecord, bundles: &HashMap<Uuid, ExerciseBundle>, ) -> Result<Self, Vec<Uuid>>

The page record describes, with exactly the exercises its exercise blocks name, taken from bundles. Errors with the exercise ids bundles doesn’t have.

Source§

impl PageSnapshot

Source

pub fn to_cms_page_update(&self) -> CmsPageUpdate

The CMS page save payload that writes this snapshot.

Source

pub fn normalize_for_storage(&mut self)

Trims and normalises the title and path the way the page save does, so that the snapshot equals the page publishing it produces.

Source

pub fn exercise_bundles(&self) -> Vec<ExerciseBundle>

The page’s exercises in exercise order, each with its slides and tasks.

Source

pub fn set_exercise_bundles<'a>( &mut self, bundles: impl IntoIterator<Item = &'a ExerciseBundle>, )

Replaces the page’s exercises, with their slides and tasks, with bundles.

Source

pub fn sort(&mut self)

Sorts the exercise lists so that two snapshots of the same page compare equal regardless of the order the database returned the rows in.

Trait Implementations§

Source§

impl Clone for PageSnapshot

Source§

fn clone(&self) -> PageSnapshot

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposeSchema for PageSnapshot

Source§

fn compose(generics: Vec<RefOr<Schema>>) -> RefOr<Schema>

Source§

impl ContentEntity for PageSnapshot

Source§

const ENTITY_TYPE: ContentEntityType = ContentEntityType::Page

Source§

fn id(&self) -> Uuid

The entity’s id; the course id for course settings.
Source§

fn course_id(&self) -> Uuid

Source§

fn label(&self) -> &str

Source§

fn parent(&self) -> Option<EntityKey>

The chapter or module the entity is placed in; None for entities of the course itself.
Source§

fn narrow(snapshot: &EntitySnapshot) -> Option<&Self>

The snapshot, if it is of this kind.
Source§

async fn load_live( conn: &mut PgConnection, ids: &[Uuid], ) -> ModelResult<HashMap<Uuid, Self>>

The live entities with the ids, as load_live_many has them, by id.
Source§

async fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>

Locks the entities’ rows until the transaction ends. Soft-deleted rows are locked too: a publish can restore them. ids must be sorted, so that concurrent lockers take the rows in the same order.
Source§

impl Debug for PageSnapshot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PageSnapshot

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&PageSnapshot> for PageRecord

Source§

fn from(page: &PageSnapshot) -> Self

Converts to this type from the input type.
Source§

impl From<PageSnapshot> for EntitySnapshot

Source§

fn from(snapshot: PageSnapshot) -> Self

Converts to this type from the input type.
Source§

impl From<PageSnapshot> for PreviewPage

Source§

fn from(page: PageSnapshot) -> Self

Converts to this type from the input type.
Source§

impl InCourseState for PageSnapshot

Source§

fn find_in(_state: &CourseState, _id: Uuid) -> Option<&Self>

The entity in state. Always None for pages, which states hold as PageRecords.
Source§

fn is_in(state: &CourseState, id: Uuid) -> bool

Source§

fn put_in(&self, state: &mut CourseState)

Adds the entity to state, or replaces it there.
Source§

fn remove_from(state: &mut CourseState, id: Uuid)

Removes the entity from state; course settings stay, since a course always has them.
Source§

impl PartialEq for PageSnapshot

Source§

fn eq(&self, other: &PageSnapshot) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PageSnapshot

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToSchema for PageSnapshot

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference [utoipa::openapi::schema::Schema]s for this type. Read more
Source§

impl StructuralPartialEq for PageSnapshot

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

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> PartialSchema for T
where T: ComposeSchema + ?Sized,

§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

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,

Decompress response bodies. Read more
§

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,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,