/// Load aggregate at current state from snapshots
Load aggregate at current state from snapshots
Load aggregate at current state from snapshots
fn load_aggregate_from_snapshot(
        &mut self,
        aggregate_id: &str,
    ) -> Result<AggregateContext<C, E, A>, Error> {
        let aggregate_type = A::aggregate_type();
        trace!(
            "loading snapshot for aggregate id '{}'",
            aggregate_id
        );
        let rows = match self.conn.query(
            SELECT_SNAPSHOT,
            &[&aggregate_type, &aggregate_id],
        ) {
            Ok(x) => x,
            Err(e) => {
                return Err(Error::new(
                    format!(
                        "unable to load snapshots table for \
                         aggregate id '{}' with error: {}",
                        &aggregate_id, e
                    )
                    .as_str(),
                ));
            },
        };
        let row = match rows.iter().next() {
            Some(x) => x,
            None => {
                trace!(
                    "returning default aggregate for aggregate id \
                     '{}'",
                    aggregate_id
                );
                return Ok(AggregateContext::new(
                    aggregate_id.to_string(),
                    0,
                    A::default(),
                ));
            },
        };
        let payload = match serde_json::from_value(row.get(1)) {
            Ok(x) => x,
            Err(e) => {
                return Err(Error::new(
                    format!(
                        "bad payload found in snapshots table for \
                         aggregate id '{}' with error: {}",
                        &aggregate_id, e
                    )
                    .as_str(),
                ));
            },
        };
        Ok(AggregateContext::new(
            aggregate_id.to_string(),
            row.get(0),
            payload,
        ))
    }
fn load_aggregate_from_snapshot ( & mut self , aggregate_id : & str , ) -> Result < AggregateContext < C , E , A > , Error > { let aggregate_type = A :: aggregate_type ( ) ; trace ! ( " " aggregate_id ) ; let rows = match self . conn . query ( SELECT_SNAPSHOT , & [ & aggregate_type , & aggregate_id ] , ) { Ok ( x ) => x , Err ( e ) => { return Err ( Error :: new ( format ! ( " \
 " aggregate_id e ) . as_str ( ) , ) ) ; } , } ; let row = match rows . iter ( ) . next ( ) { Some ( x ) => x , None => { trace ! ( " \
 " aggregate_id ) ; return Ok ( AggregateContext :: new ( aggregate_id . to_string ( ) , 0 , A :: default ( ) , ) ) ; } , } ; let payload = match serde_json :: from_value ( row . get ( 1 ) ) { Ok ( x ) => x , Err ( e ) => { return Err ( Error :: new ( format ! ( " \
 " aggregate_id e ) . as_str ( ) , ) ) ; } , } ; Ok ( AggregateContext :: new ( aggregate_id . to_string ( ) , row . get ( 0 ) , payload , ) ) }
Load aggregate at current state from snapshots
Load aggregate at current state from snapshots
&mut self
aggregate_id
&str