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 result: Option<Row> = match self.conn.exec_first(
            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 result {
            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 version: i64 = row.get(0).unwrap();
        let payload: String = row.get(1).unwrap();

        let payload = match serde_json::from_str(payload.as_str()) {
            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(),
            version,
            payload,
        ))
    }
/// 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 result: Option<Row> = match self.conn.exec_first(
            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 result {
            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 version: i64 = row.get(0).unwrap();
        let payload: String = row.get(1).unwrap();
        let payload = match serde_json::from_str(payload.as_str()) {
            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(),
            version,
            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 result : Option < Row > = match self . conn . exec_first ( SELECT_SNAPSHOT , ( & aggregate_type , & aggregate_id ) , ) { Ok ( x ) => x , Err ( e ) => { return Err ( Error :: new ( format ! ( " \
 " aggregate_id e ) . as_str ( ) , ) ) ; } , } ; let row = match result { Some ( x ) => x , None => { trace ! ( " \
 " aggregate_id ) ; return Ok ( AggregateContext :: new ( aggregate_id . to_string ( ) , 0 , A :: default ( ) , ) ) ; } , } ; let version : i64 = row . get ( 0 ) . unwrap ( ) ; let payload : String = row . get ( 1 ) . unwrap ( ) ; let payload = match serde_json :: from_str ( payload . as_str ( ) ) { Ok ( x ) => x , Err ( e ) => { return Err ( Error :: new ( format ! ( " \
 " aggregate_id e ) . as_str ( ) , ) ) ; } , } ; Ok ( AggregateContext :: new ( aggregate_id . to_string ( ) , version , payload , ) ) }
Load aggregate at current state from snapshots
Load aggregate at current state from snapshots
&mut self
aggregate_id
&str
&mut self
aggregate_id
&str