pub fn parse_mutation(
    cursor: &mut Cursor,
    temporaries: &mut Temporaries,
) -> Result<Mutation> {
    use std::iter;

    // The first part is the same as for a regular query.
    let variable_names = parse_strings(cursor)?;
    let where_statements = parse_statements(cursor, temporaries)?;
    let selects = parse_variables(cursor)?;

    // Then we get the assertions.
    let assertions = parse_statements(cursor, temporaries)?;

    // Determine which variables are bound, by marking all variables that
    // occur in the "where" part as bound.
    let mut is_bound: Vec<bool> = iter::repeat(false)
        .take(variable_names.len())
        .collect();

    for statement in where_statements.iter() {
        // TODO: Guard against malicious inputs, report error on index out
        // of bounds.
        is_bound[statement.entity.0 as usize] = true;

        if let QueryValue::Var(v) = statement.value {
            is_bound[v.0 as usize] = true;
        }
    }

    // From the bound/free bitmap, produce two collections with variables.
    // These are mainly used for convenience.
    let mut bound_variables = Vec::with_capacity(variable_names.len());
    let mut free_variables = Vec::with_capacity(variable_names.len());
    let mut was_bound = true;
    for (i, &bound) in is_bound.iter().enumerate() {
        if bound {
            bound_variables.push(Var(i as u16));
            assert!(was_bound, "Bound variables must precede free variables.");
        } else {
            free_variables.push(Var(i as u16));
            was_bound = false;
        }
    }

    let mutation = Mutation {
        variable_names: variable_names,
        where_statements: where_statements,
        assertions: assertions,
        bound_variables: bound_variables,
        free_variables: free_variables,
        select: selects,
    };

    Ok(mutation)
}
/// Deserialize a mutation request in binary format.
Deserialize a mutation request in binary format.
Deserialize a mutation request in binary format .
pub fn parse_mutation(
    cursor: &mut Cursor,
    temporaries: &mut Temporaries,
) -> Result<Mutation> {
    use std::iter;
    // The first part is the same as for a regular query.
    let variable_names = parse_strings(cursor)?;
    let where_statements = parse_statements(cursor, temporaries)?;
    let selects = parse_variables(cursor)?;
    // Then we get the assertions.
    let assertions = parse_statements(cursor, temporaries)?;
    // Determine which variables are bound, by marking all variables that
    // occur in the "where" part as bound.
    let mut is_bound: Vec<bool> = iter::repeat(false)
        .take(variable_names.len())
        .collect();
    for statement in where_statements.iter() {
        // TODO: Guard against malicious inputs, report error on index out
        // of bounds.
        is_bound[statement.entity.0 as usize] = true;
        if let QueryValue::Var(v) = statement.value {
            is_bound[v.0 as usize] = true;
        }
    }
    // From the bound/free bitmap, produce two collections with variables.
    // These are mainly used for convenience.
    let mut bound_variables = Vec::with_capacity(variable_names.len());
    let mut free_variables = Vec::with_capacity(variable_names.len());
    let mut was_bound = true;
    for (i, &bound) in is_bound.iter().enumerate() {
        if bound {
            bound_variables.push(Var(i as u16));
            assert!(was_bound, "Bound variables must precede free variables.");
        } else {
            free_variables.push(Var(i as u16));
            was_bound = false;
        }
    }
    let mutation = Mutation {
        variable_names: variable_names,
        where_statements: where_statements,
        assertions: assertions,
        bound_variables: bound_variables,
        free_variables: free_variables,
        select: selects,
    };
    Ok(mutation)
}
pub fn parse_mutation ( cursor : & mut Cursor , temporaries : & mut Temporaries , ) -> Result < Mutation > { use std :: iter ; // The first part is the same as for a regular query. let variable_names = parse_strings ( cursor ) ? ; let where_statements = parse_statements ( cursor , temporaries ) ? ; let selects = parse_variables ( cursor ) ? ; // Then we get the assertions. let assertions = parse_statements ( cursor , temporaries ) ? ; // Determine which variables are bound, by marking all variables that // occur in the "where" part as bound. let mut is_bound : Vec < bool > = iter :: repeat ( false ) . take ( variable_names . len ( ) ) . collect ( ) ; for statement in where_statements . iter ( ) { // TODO: Guard against malicious inputs, report error on index out // of bounds. is_bound [ statement . entity . 0 as usize ] = true ; if let QueryValue :: Var ( v ) = statement . value { is_bound [ v . 0 as usize ] = true ; } } // From the bound/free bitmap, produce two collections with variables. // These are mainly used for convenience. let mut bound_variables = Vec :: with_capacity ( variable_names . len ( ) ) ; let mut free_variables = Vec :: with_capacity ( variable_names . len ( ) ) ; let mut was_bound = true ; for ( i , & bound ) in is_bound . iter ( ) . enumerate ( ) { if bound { bound_variables . push ( Var ( i as u16 ) ) ; assert ! ( was_bound " " ) ; } else { free_variables . push ( Var ( i as u16 ) ) ; was_bound = false ; } } let mutation = Mutation { variable_names : variable_names , where_statements : where_statements , assertions : assertions , bound_variables : bound_variables , free_variables : free_variables , select : selects , } ; Ok ( mutation ) }
Deserialize a mutation request in binary format.
Deserialize a mutation request in binary format .
cursor
&mut Cursor
temporaries
&mut Temporaries
cursor
&mut Cursor
temporaries
&mut Temporaries