A MsgId newtype

This more strongly types the ubiquitous message id type by no longer
making it an integer.  It keeps the actual ID opaque.  Only for the
generic job API the number keeps being used.  Some locations also need
to create it from an integer and call MsgId::new().
This commit is contained in:
Floris Bruynooghe
2019-10-20 23:47:48 +02:00
committed by holger krekel
parent c6adbe939d
commit c8d296ea0e
18 changed files with 806 additions and 465 deletions

View File

@@ -11,7 +11,7 @@ use crate::dc_tools::*;
use crate::error::Error;
use crate::events::Event;
use crate::job::*;
use crate::message::Message;
use crate::message::{Message, MsgId};
use crate::param::*;
use crate::sql;
use crate::stock::StockMessage;
@@ -475,12 +475,16 @@ pub fn set_kml_sent_timestamp(
Ok(())
}
pub fn set_msg_location_id(context: &Context, msg_id: u32, location_id: u32) -> Result<(), Error> {
pub fn set_msg_location_id(
context: &Context,
msg_id: MsgId,
location_id: u32,
) -> Result<(), Error> {
sql::execute(
context,
&context.sql,
"UPDATE msgs SET location_id=? WHERE id=?;",
params![location_id, msg_id as i32],
params![location_id, msg_id],
)?;
Ok(())