Move ContactId constants to struct.

This makes the APIs much more Rust-like and keep contact IDs clearer
and in one place.
This commit is contained in:
Floris Bruynooghe
2022-04-03 14:08:27 +02:00
parent 918ee47c79
commit 35c0434dc7
20 changed files with 243 additions and 267 deletions

View File

@@ -1949,7 +1949,7 @@ pub unsafe extern "C" fn dc_block_contact(
contact_id: u32,
block: libc::c_int,
) {
if context.is_null() || contact_id <= constants::DC_CONTACT_ID_LAST_SPECIAL.to_u32() {
if context.is_null() || contact_id <= ContactId::LAST_SPECIAL.to_u32() {
eprintln!("ignoring careless call to dc_block_contact()");
return;
}
@@ -1994,7 +1994,7 @@ pub unsafe extern "C" fn dc_delete_contact(
context: *mut dc_context_t,
contact_id: u32,
) -> libc::c_int {
if context.is_null() || contact_id <= constants::DC_CONTACT_ID_LAST_SPECIAL.to_u32() {
if context.is_null() || contact_id <= ContactId::LAST_SPECIAL.to_u32() {
eprintln!("ignoring careless call to dc_delete_contact()");
return 0;
}