pub struct Session {
pub state: String,
pub model: Option<String>,
pub calibration: Option<f64>,
pub questions: Vec<QuestionDraft>,
}Fields§
§state: String§model: Option<String>§calibration: Option<f64>§questions: Vec<QuestionDraft>Implementations§
Source§impl Session
impl Session
Sourcepub fn load_from(path: &Path) -> Self
pub fn load_from(path: &Path) -> Self
Read a session, or return an empty one for any reason at all.
pub fn load() -> Self
Sourcepub fn save_to(&self, path: &Path) -> Result<()>
pub fn save_to(&self, path: &Path) -> Result<()>
Write the session beside path and rename it into place, so the file is always either
the old session or the new one. Written in place, a crash between truncating and writing
would leave a broken file, which loads as an empty form without a word.
Sourcepub fn clear_at(path: &Path) -> Result<()>
pub fn clear_at(path: &Path) -> Result<()>
Forget the saved session. Emptying the form is a deliberate act, and leaving the old file behind would bring back on the next start what was just cleared.
Sourcepub fn persist(&self) -> Result<()>
pub fn persist(&self) -> Result<()>
Save a form worth keeping, or forget the saved one when the form is empty. Failure is reported rather than swallowed — the caller decides whether it is worth a message.
Sourcepub fn build<'a>(&self, client: &'a Client) -> SystemOne<'a>
pub fn build<'a>(&self, client: &'a Client) -> SystemOne<'a>
Assemble the request this form describes, through the SDK’s own builder.
The request is built from the session rather than from the live widgets for two reasons. It makes what gets saved and what gets sent the same thing by construction — a reloaded form cannot send something different from the one that was saved. And it hands the background task an owned snapshot, so the request in flight is the form as it was when you pressed send, not as you have edited it since.
Nothing is validated here. cerno-core owns those rules, the OpenAPI document publishes
them, and the service names both the offending question and what to do instead. A fourth
copy in the client would be the one that drifts.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§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