Skip to content

Commit e63dfb5

Browse files
authored
Merge pull request #328 from korpling/update-rust-edition
Update rust edition to 2024
2 parents 3196ccf + 74e7c87 commit e63dfb5

89 files changed

Lines changed: 1334 additions & 1407 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[workspace]
22
members = [
3-
"core",
4-
"graphannis",
5-
"cli",
6-
"capi",
7-
"webservice",
8-
"examples/tutorial",
3+
"core",
4+
"graphannis",
5+
"cli",
6+
"capi",
7+
"webservice",
8+
"examples/tutorial",
99
]
10-
resolver = "2"
10+
resolver = "3"
1111

1212
# Config for 'cargo dist'
1313
[workspace.metadata.dist]
@@ -21,10 +21,10 @@ installers = []
2121
pr-run-mode = "plan"
2222
# Target platforms to build apps for (Rust target-triple syntax)
2323
targets = [
24-
"aarch64-apple-darwin",
25-
"x86_64-apple-darwin",
26-
"x86_64-unknown-linux-gnu",
27-
"x86_64-pc-windows-msvc",
24+
"aarch64-apple-darwin",
25+
"x86_64-apple-darwin",
26+
"x86_64-unknown-linux-gnu",
27+
"x86_64-pc-windows-msvc",
2828
]
2929
[workspace.metadata.dist.github-custom-runners]
3030
global = "ubuntu-22.04"

capi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
authors = ["Thomas Krause <thomaskrause@posteo.de>"]
33
description = "This is the C-API to the ANNIS linguistic search and visualization system."
4-
edition = "2018"
4+
edition = "2024"
55
license = "Apache-2.0"
66
name = "graphannis-capi"
77
readme = "crate-info.md"

capi/src/cerror.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ pub fn new(err: Box<dyn StdError>) -> *mut ErrorList {
103103
}
104104

105105
/// Returns the number of errors in the list.
106-
#[no_mangle]
106+
#[unsafe(no_mangle)]
107107
pub extern "C" fn annis_error_size(ptr: *const ErrorList) -> size_t {
108108
vec_size(ptr)
109109
}
110110

111111
/// Get the message for the error at position `i` in the list.
112-
#[no_mangle]
112+
#[unsafe(no_mangle)]
113113
pub extern "C" fn annis_error_get_msg(ptr: *const ErrorList, i: size_t) -> *const c_char {
114114
let item = vec_get(ptr, i);
115115
if item.is_null() {
@@ -120,7 +120,7 @@ pub extern "C" fn annis_error_get_msg(ptr: *const ErrorList, i: size_t) -> *cons
120120
}
121121

122122
/// Get the kind or type for the error at position `i` in the list.
123-
#[no_mangle]
123+
#[unsafe(no_mangle)]
124124
pub extern "C" fn annis_error_get_kind(ptr: *const ErrorList, i: size_t) -> *const c_char {
125125
let item = vec_get(ptr, i);
126126
if item.is_null() {

capi/src/corpusstorage.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use super::cerror::ErrorList;
21
use super::Matrix;
2+
use super::cerror::ErrorList;
33
use super::{cast_const, cast_mut, cstr, map_cerr};
44
use graphannis::corpusstorage::ExportFormat;
55
use graphannis::{
6+
AnnotationGraph, CorpusStorage,
67
corpusstorage::{
78
CacheStrategy, CountExtra, FrequencyDefEntry, FrequencyTable, FrequencyTableRow,
89
ImportFormat, QueryAttributeDescription, QueryLanguage, ResultOrder, SearchQuery,
910
},
1011
model::{AnnotationComponent, AnnotationComponentType},
1112
update::GraphUpdate,
12-
AnnotationGraph, CorpusStorage,
1313
};
1414
use std::ffi::CString;
1515
use std::path::PathBuf;
@@ -22,7 +22,7 @@ use std::path::PathBuf;
2222
/// - `db_dir` - The path on the filesystem where the corpus storage content is located. Must be an existing directory.
2323
/// - `use_parallel_joins` - If `true` parallel joins are used by the system, using all available cores.
2424
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
25-
#[no_mangle]
25+
#[unsafe(no_mangle)]
2626
pub extern "C" fn annis_cs_with_auto_cache_size(
2727
db_dir: *const libc::c_char,
2828
use_parallel_joins: bool,
@@ -45,7 +45,7 @@ pub extern "C" fn annis_cs_with_auto_cache_size(
4545
/// - `max_cache_size` - Fixed maximum size of the cache in bytes.
4646
/// - `use_parallel_joins` - If `true` parallel joins are used by the system, using all available cores.
4747
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
48-
#[no_mangle]
48+
#[unsafe(no_mangle)]
4949
pub extern "C" fn annis_cs_with_max_cache_size(
5050
db_dir: *const libc::c_char,
5151
max_cache_size: usize,
@@ -73,13 +73,13 @@ pub extern "C" fn annis_cs_with_max_cache_size(
7373
/// # Safety
7474
///
7575
/// This functions dereferences the pointer given as argument and is therefore unsafe.
76-
#[no_mangle]
76+
#[unsafe(no_mangle)]
7777
pub unsafe extern "C" fn annis_cs_free(ptr: *mut CorpusStorage) {
7878
if ptr.is_null() {
7979
return;
8080
}
8181
// take ownership and destroy the pointer
82-
let ptr = Box::from_raw(ptr);
82+
let ptr = unsafe { Box::from_raw(ptr) };
8383
std::mem::drop(ptr);
8484
}
8585

@@ -91,7 +91,7 @@ pub unsafe extern "C" fn annis_cs_free(ptr: *mut CorpusStorage) {
9191
/// - `err` - Pointer to a list of errors. If any error occurred, this list will be non-empty.
9292
///
9393
/// Returns the count as number.
94-
#[no_mangle]
94+
#[unsafe(no_mangle)]
9595
pub extern "C" fn annis_cs_count(
9696
ptr: *const CorpusStorage,
9797
corpus_names: *const Vec<CString>,
@@ -124,7 +124,7 @@ pub extern "C" fn annis_cs_count(
124124
/// - `query` - The query as string.
125125
/// - `query_language` The query language of the query (e.g. AQL).
126126
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
127-
#[no_mangle]
127+
#[unsafe(no_mangle)]
128128
pub extern "C" fn annis_cs_count_extra(
129129
ptr: *const CorpusStorage,
130130
corpus_names: *const Vec<CString>,
@@ -168,7 +168,7 @@ pub extern "C" fn annis_cs_count_extra(
168168
/// # Safety
169169
///
170170
/// This functions dereferences the `err` pointer and is therefore unsafe.
171-
#[no_mangle]
171+
#[unsafe(no_mangle)]
172172
pub unsafe extern "C" fn annis_cs_find(
173173
ptr: *const CorpusStorage,
174174
corpus_names: *const Vec<CString>,
@@ -194,7 +194,7 @@ pub unsafe extern "C" fn annis_cs_find(
194194
timeout: None,
195195
};
196196

197-
let limit = if limit.is_null() { None } else { Some(*limit) };
197+
let limit = unsafe { if limit.is_null() { None } else { Some(*limit) } };
198198

199199
map_cerr(cs.find(search_query, offset, limit, order), err)
200200
.map(|result| {
@@ -221,7 +221,7 @@ pub unsafe extern "C" fn annis_cs_find(
221221
/// # Safety
222222
///
223223
/// This functions dereferences the `err` pointer and is therefore unsafe.
224-
#[no_mangle]
224+
#[unsafe(no_mangle)]
225225
pub extern "C" fn annis_cs_subgraph(
226226
ptr: *const CorpusStorage,
227227
corpus_name: *const libc::c_char,
@@ -262,7 +262,7 @@ pub extern "C" fn annis_cs_subgraph(
262262
/// # Safety
263263
///
264264
/// This functions dereferences the `err` pointer and is therefore unsafe.
265-
#[no_mangle]
265+
#[unsafe(no_mangle)]
266266
pub extern "C" fn annis_cs_subcorpus_graph(
267267
ptr: *const CorpusStorage,
268268
corpus_name: *const libc::c_char,
@@ -285,7 +285,7 @@ pub extern "C" fn annis_cs_subcorpus_graph(
285285
///
286286
/// - `ptr` - The corpus storage object.
287287
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
288-
#[no_mangle]
288+
#[unsafe(no_mangle)]
289289
pub extern "C" fn annis_cs_corpus_graph(
290290
ptr: *const CorpusStorage,
291291
corpus_name: *const libc::c_char,
@@ -306,7 +306,7 @@ pub extern "C" fn annis_cs_corpus_graph(
306306
/// - `query` - The query which defines included nodes.
307307
/// - `query_language` - The query language of the query (e.g. AQL).
308308
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
309-
#[no_mangle]
309+
#[unsafe(no_mangle)]
310310
pub extern "C" fn annis_cs_subgraph_for_query(
311311
ptr: *const CorpusStorage,
312312
corpus_name: *const libc::c_char,
@@ -334,7 +334,7 @@ pub extern "C" fn annis_cs_subgraph_for_query(
334334
/// - `query_language` - The query language of the query (e.g. AQL).
335335
/// - `component_type_filter` - Only include edges of that belong to a component of the given type.
336336
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
337-
#[no_mangle]
337+
#[unsafe(no_mangle)]
338338
pub extern "C" fn annis_cs_subgraph_for_query_with_ctype(
339339
ptr: *const CorpusStorage,
340340
corpus_name: *const libc::c_char,
@@ -365,7 +365,7 @@ pub extern "C" fn annis_cs_subgraph_for_query_with_ctype(
365365
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
366366
///
367367
/// Returns a frequency table of strings.
368-
#[no_mangle]
368+
#[unsafe(no_mangle)]
369369
pub extern "C" fn annis_cs_frequency(
370370
ptr: *const CorpusStorage,
371371
corpus_names: *const Vec<CString>,
@@ -424,7 +424,7 @@ pub extern "C" fn annis_cs_frequency(
424424
///
425425
/// - `ptr` - The corpus storage object.
426426
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
427-
#[no_mangle]
427+
#[unsafe(no_mangle)]
428428
pub extern "C" fn annis_cs_list(
429429
ptr: *const CorpusStorage,
430430
err: *mut *mut ErrorList,
@@ -451,7 +451,7 @@ pub extern "C" fn annis_cs_list(
451451
/// - `list_values` - If true include the possible values in the result.
452452
/// - `only_most_frequent_values` - If both this argument and `list_values` are true, only return the most frequent value for each annotation name.
453453
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
454-
#[no_mangle]
454+
#[unsafe(no_mangle)]
455455
pub extern "C" fn annis_cs_list_node_annotations(
456456
ptr: *const CorpusStorage,
457457
corpus_name: *const libc::c_char,
@@ -491,7 +491,7 @@ pub extern "C" fn annis_cs_list_node_annotations(
491491
/// - `component_layer` - The layer of the edge component.
492492
/// - `only_most_frequent_values` - If both this argument and `list_values` are true, only return the most frequent value for each annotation name.
493493
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
494-
#[no_mangle]
494+
#[unsafe(no_mangle)]
495495
pub extern "C" fn annis_cs_list_edge_annotations(
496496
ptr: *const CorpusStorage,
497497
corpus_name: *const libc::c_char,
@@ -539,7 +539,7 @@ pub extern "C" fn annis_cs_list_edge_annotations(
539539
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
540540
///
541541
/// Returns `true` if valid and an error with the parser message if invalid.
542-
#[no_mangle]
542+
#[unsafe(no_mangle)]
543543
pub extern "C" fn annis_cs_validate_query(
544544
ptr: *const CorpusStorage,
545545
corpus_names: *const Vec<CString>,
@@ -568,7 +568,7 @@ pub extern "C" fn annis_cs_validate_query(
568568
/// - `query` - The query to be analyzed.
569569
/// - `query_language` - The query language of the query (e.g. AQL).
570570
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
571-
#[no_mangle]
571+
#[unsafe(no_mangle)]
572572
pub extern "C" fn annis_cs_node_descriptions(
573573
ptr: *const CorpusStorage,
574574
query: *const libc::c_char,
@@ -595,7 +595,7 @@ pub extern "C" fn annis_cs_node_descriptions(
595595
///
596596
/// Returns the name of the imported corpus.
597597
/// The returned string must be deallocated by the caller using annis_str_free()!
598-
#[no_mangle]
598+
#[unsafe(no_mangle)]
599599
pub extern "C" fn annis_cs_import_from_fs(
600600
ptr: *mut CorpusStorage,
601601
path: *const libc::c_char,
@@ -639,7 +639,7 @@ pub extern "C" fn annis_cs_import_from_fs(
639639
/// - `path` - The location on the file system where the corpus data should be written to.
640640
/// - `format` - The format in which this corpus data will be stored stored.
641641
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
642-
#[no_mangle]
642+
#[unsafe(no_mangle)]
643643
pub extern "C" fn annis_cs_export_to_fs(
644644
ptr: *mut CorpusStorage,
645645
corpus_names: *const Vec<CString>,
@@ -664,7 +664,7 @@ pub extern "C" fn annis_cs_export_to_fs(
664664
/// - `ptr` - The corpus storage object.
665665
/// - `ctype` -Filter by the component type.
666666
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
667-
#[no_mangle]
667+
#[unsafe(no_mangle)]
668668
pub extern "C" fn annis_cs_list_components_by_type(
669669
ptr: *mut CorpusStorage,
670670
corpus_name: *const libc::c_char,
@@ -684,7 +684,7 @@ pub extern "C" fn annis_cs_list_components_by_type(
684684
///
685685
/// - `ptr` - The corpus storage object.
686686
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
687-
#[no_mangle]
687+
#[unsafe(no_mangle)]
688688
pub extern "C" fn annis_cs_delete(
689689
ptr: *mut CorpusStorage,
690690
corpus: *const libc::c_char,
@@ -700,7 +700,7 @@ pub extern "C" fn annis_cs_delete(
700700
///
701701
/// - `corpus` The name of the corpus to unload.
702702
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
703-
#[no_mangle]
703+
#[unsafe(no_mangle)]
704704
pub extern "C" fn annis_cs_unload(
705705
ptr: *mut CorpusStorage,
706706
corpus: *const libc::c_char,
@@ -718,7 +718,7 @@ pub extern "C" fn annis_cs_unload(
718718
/// - `err` - Pointer to a list of errors. If any error occured, this list will be non-empty.
719719
///
720720
/// It is ensured that the update process is atomic and that the changes are persisted to disk if the error list is empty.
721-
#[no_mangle]
721+
#[unsafe(no_mangle)]
722722
pub extern "C" fn annis_cs_apply_update(
723723
ptr: *mut CorpusStorage,
724724
corpus_name: *const libc::c_char,

0 commit comments

Comments
 (0)