pub struct CalibrationSession<P>where
P: ProblemType,{
pub metadata: SessionMetadata,
pub config: <P as ProblemType>::Config,
pub state: <P as ProblemType>::State,
pub exports: Vec<ExportRecord<<P as ProblemType>::Export>>,
pub log: Vec<LogEntry>,
/* private fields */
}Expand description
A calibration session container with mutable state.
The session stores configuration, input data, intermediate state, and the final output. Step functions mutate the session in-place.
§Design Principles
- Single output: Only one final result is stored.
- Embedded input: Input data is stored directly in the session.
- Config changes don’t auto-clear: Changing config doesn’t invalidate output.
- Exports collection: Multiple exports can be generated and stored.
§Example
use vision_calibration_pipeline::session::CalibrationSession;
use vision_calibration_pipeline::planar_intrinsics::{PlanarIntrinsicsProblem, step_init, step_optimize};
let mut session = CalibrationSession::<PlanarIntrinsicsProblem>::new();
session.set_input(dataset)?;
step_init(&mut session, None)?;
step_optimize(&mut session, None)?;
let export = session.export()?;Fields§
§metadata: SessionMetadataSession metadata (problem type, schema version, timestamps, description).
config: <P as ProblemType>::ConfigConfiguration parameters (always present, defaults if not explicitly set).
state: <P as ProblemType>::StateProblem-specific intermediate state (default until computed).
exports: Vec<ExportRecord<<P as ProblemType>::Export>>Collection of generated exports.
log: Vec<LogEntry>Operation log (lightweight audit trail).
Implementations§
Source§impl<P> CalibrationSession<P>where
P: ProblemType,
impl<P> CalibrationSession<P>where
P: ProblemType,
Sourcepub fn new() -> CalibrationSession<P>
pub fn new() -> CalibrationSession<P>
Create a new empty session with default configuration.
Sourcepub fn with_description(description: impl Into<String>) -> CalibrationSession<P>
pub fn with_description(description: impl Into<String>) -> CalibrationSession<P>
Create a new session with a description.
Sourcepub fn with_input(
input: <P as ProblemType>::Input,
) -> Result<CalibrationSession<P>, Error>
pub fn with_input( input: <P as ProblemType>::Input, ) -> Result<CalibrationSession<P>, Error>
Sourcepub fn set_input(
&mut self,
input: <P as ProblemType>::Input,
) -> Result<(), Error>
pub fn set_input( &mut self, input: <P as ProblemType>::Input, ) -> Result<(), Error>
Set input data, applying validation and invalidation policy.
§Errors
Returns an error if ProblemType::validate_input fails.
Sourcepub fn input(&self) -> Option<&<P as ProblemType>::Input>
pub fn input(&self) -> Option<&<P as ProblemType>::Input>
Get a reference to the input, if set.
Sourcepub fn input_mut(&mut self) -> Option<&mut <P as ProblemType>::Input>
pub fn input_mut(&mut self) -> Option<&mut <P as ProblemType>::Input>
Get a mutable reference to the input, if set.
Sourcepub fn require_input(&self) -> Result<&<P as ProblemType>::Input, Error>
pub fn require_input(&self) -> Result<&<P as ProblemType>::Input, Error>
Sourcepub fn require_input_mut(
&mut self,
) -> Result<&mut <P as ProblemType>::Input, Error>
pub fn require_input_mut( &mut self, ) -> Result<&mut <P as ProblemType>::Input, Error>
Get a mutable reference to the input, or error if not set.
§Errors
Returns an error if input is not set.
Sourcepub fn clear_input(&mut self)
pub fn clear_input(&mut self)
Clear input data, applying invalidation policy.
Sourcepub fn set_config(
&mut self,
config: <P as ProblemType>::Config,
) -> Result<(), Error>
pub fn set_config( &mut self, config: <P as ProblemType>::Config, ) -> Result<(), Error>
Set configuration, applying validation and invalidation policy.
§Errors
Returns an error if ProblemType::validate_config fails.
Sourcepub fn update_config<F>(&mut self, f: F) -> Result<(), Error>
pub fn update_config<F>(&mut self, f: F) -> Result<(), Error>
Update configuration with a closure.
The closure receives a mutable reference to the current config. After the closure returns, validation and invalidation policy are applied.
§Errors
Returns an error if validation fails after the update.
Sourcepub fn output(&self) -> Option<&<P as ProblemType>::Output>
pub fn output(&self) -> Option<&<P as ProblemType>::Output>
Get a reference to the output, if computed.
Sourcepub fn output_mut(&mut self) -> Option<&mut <P as ProblemType>::Output>
pub fn output_mut(&mut self) -> Option<&mut <P as ProblemType>::Output>
Get a mutable reference to the output, if computed.
Sourcepub fn require_output(&self) -> Result<&<P as ProblemType>::Output, Error>
pub fn require_output(&self) -> Result<&<P as ProblemType>::Output, Error>
Get a reference to the output, or error if not computed.
§Errors
Returns an error if output is not computed.
Sourcepub fn set_output(&mut self, output: <P as ProblemType>::Output)
pub fn set_output(&mut self, output: <P as ProblemType>::Output)
Set the output (typically called by step functions).
Sourcepub fn has_output(&self) -> bool
pub fn has_output(&self) -> bool
Check if output is computed.
Sourcepub fn clear_output(&mut self)
pub fn clear_output(&mut self)
Clear output.
Sourcepub fn export(&mut self) -> Result<<P as ProblemType>::Export, Error>
pub fn export(&mut self) -> Result<<P as ProblemType>::Export, Error>
Export the current output and add to exports collection.
§Errors
Returns an error if output is not computed or if export conversion fails.
Sourcepub fn export_with_notes(
&mut self,
notes: impl Into<String>,
) -> Result<<P as ProblemType>::Export, Error>
pub fn export_with_notes( &mut self, notes: impl Into<String>, ) -> Result<<P as ProblemType>::Export, Error>
Export the current output with notes and add to exports collection.
§Errors
Returns an error if output is not computed or if export conversion fails.
Sourcepub fn export_peek(&self) -> Result<<P as ProblemType>::Export, Error>
pub fn export_peek(&self) -> Result<<P as ProblemType>::Export, Error>
Export without adding to collection (peek).
Useful for inspecting the export without modifying the session.
§Errors
Returns an error if output is not computed or if export conversion fails.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validate that the session is ready for processing.
Checks:
- Input is set and valid
- Config is valid
- Input and config are compatible (cross-validation)
§Errors
Returns an error if any validation check fails.
Sourcepub fn log_success(&mut self, operation: impl Into<String>)
pub fn log_success(&mut self, operation: impl Into<String>)
Log a successful operation.
Sourcepub fn log_success_with_notes(
&mut self,
operation: impl Into<String>,
notes: impl Into<String>,
)
pub fn log_success_with_notes( &mut self, operation: impl Into<String>, notes: impl Into<String>, )
Log a successful operation with notes.
Sourcepub fn log_failure(
&mut self,
operation: impl Into<String>,
error: impl Into<String>,
)
pub fn log_failure( &mut self, operation: impl Into<String>, error: impl Into<String>, )
Log a failed operation.
Sourcepub fn reset_state(&mut self)
pub fn reset_state(&mut self)
Reset state to default, keeping input, config, and output.
Sourcepub fn reset_output(&mut self)
pub fn reset_output(&mut self)
Reset output, keeping input, config, and state.
Trait Implementations§
Source§impl<P> Clone for CalibrationSession<P>where
P: Clone + ProblemType,
<P as ProblemType>::Config: Clone,
<P as ProblemType>::Input: Clone,
<P as ProblemType>::State: Clone,
<P as ProblemType>::Output: Clone,
<P as ProblemType>::Export: Clone,
impl<P> Clone for CalibrationSession<P>where
P: Clone + ProblemType,
<P as ProblemType>::Config: Clone,
<P as ProblemType>::Input: Clone,
<P as ProblemType>::State: Clone,
<P as ProblemType>::Output: Clone,
<P as ProblemType>::Export: Clone,
Source§fn clone(&self) -> CalibrationSession<P>
fn clone(&self) -> CalibrationSession<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Debug for CalibrationSession<P>where
P: Debug + ProblemType,
<P as ProblemType>::Config: Debug,
<P as ProblemType>::Input: Debug,
<P as ProblemType>::State: Debug,
<P as ProblemType>::Output: Debug,
<P as ProblemType>::Export: Debug,
impl<P> Debug for CalibrationSession<P>where
P: Debug + ProblemType,
<P as ProblemType>::Config: Debug,
<P as ProblemType>::Input: Debug,
<P as ProblemType>::State: Debug,
<P as ProblemType>::Output: Debug,
<P as ProblemType>::Export: Debug,
Source§impl<P> Default for CalibrationSession<P>where
P: ProblemType,
impl<P> Default for CalibrationSession<P>where
P: ProblemType,
Source§fn default() -> CalibrationSession<P>
fn default() -> CalibrationSession<P>
Source§impl<'de, P> Deserialize<'de> for CalibrationSession<P>where
P: ProblemType,
impl<'de, P> Deserialize<'de> for CalibrationSession<P>where
P: ProblemType,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CalibrationSession<P>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CalibrationSession<P>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<P> Serialize for CalibrationSession<P>where
P: ProblemType,
impl<P> Serialize for CalibrationSession<P>where
P: ProblemType,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl<P> Freeze for CalibrationSession<P>where
<P as ProblemType>::Config: Freeze,
<P as ProblemType>::State: Freeze,
<P as ProblemType>::Input: Freeze,
<P as ProblemType>::Output: Freeze,
impl<P> RefUnwindSafe for CalibrationSession<P>where
<P as ProblemType>::Config: RefUnwindSafe,
<P as ProblemType>::State: RefUnwindSafe,
<P as ProblemType>::Input: RefUnwindSafe,
<P as ProblemType>::Output: RefUnwindSafe,
<P as ProblemType>::Export: RefUnwindSafe,
impl<P> Send for CalibrationSession<P>where
<P as ProblemType>::Config: Send,
<P as ProblemType>::State: Send,
<P as ProblemType>::Input: Send,
<P as ProblemType>::Output: Send,
<P as ProblemType>::Export: Send,
impl<P> Sync for CalibrationSession<P>where
<P as ProblemType>::Config: Sync,
<P as ProblemType>::State: Sync,
<P as ProblemType>::Input: Sync,
<P as ProblemType>::Output: Sync,
<P as ProblemType>::Export: Sync,
impl<P> Unpin for CalibrationSession<P>where
<P as ProblemType>::Config: Unpin,
<P as ProblemType>::State: Unpin,
<P as ProblemType>::Input: Unpin,
<P as ProblemType>::Output: Unpin,
<P as ProblemType>::Export: Unpin,
impl<P> UnsafeUnpin for CalibrationSession<P>where
<P as ProblemType>::Config: UnsafeUnpin,
<P as ProblemType>::State: UnsafeUnpin,
<P as ProblemType>::Input: UnsafeUnpin,
<P as ProblemType>::Output: UnsafeUnpin,
impl<P> UnwindSafe for CalibrationSession<P>where
<P as ProblemType>::Config: UnwindSafe,
<P as ProblemType>::State: UnwindSafe,
<P as ProblemType>::Input: UnwindSafe,
<P as ProblemType>::Output: UnwindSafe,
<P as ProblemType>::Export: UnwindSafe,
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,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.