1pub const MAX_WIRE_MESSAGE_BYTES: usize = 16 * 1024 * 1024;
8
9mod arity;
10mod auto_literal;
11mod cancel;
12pub mod ce_messages;
13mod convert;
14mod convert_walk;
15pub mod deadline;
16mod dynamic;
17mod error;
18mod error_kinds;
23pub mod file_identity;
24pub mod integer_args;
25mod literal;
26mod load_pool;
27mod memory_limit;
28mod namespace;
29mod output_safety;
30mod presence_bits;
31mod preview;
32pub mod temporal;
33pub mod tokens;
34mod traversal;
35mod typename;
36mod value;
37
38pub use arity::{
39 builtin_arity, ArityContract, CHAR_LENGTH_ARITY, FORMAT_ARITY, FUNCTION_REQUIRES_ONE_ARGUMENT,
40 LENGTH_REQUIRES_A_PATH, NULLIF_ARITY, VECTOR_ARITY,
41};
42pub use auto_literal::{auto_literal, AutoLiteralGuard};
43pub use cancel::CancelToken;
44pub use convert::{
45 column_type_name, cypher_to_value, plan_value_to_cypher, value_to_cypher, MAX_PLAN_WIRE_DEPTH,
46};
47pub use dynamic::{
48 dynamic_label_names, dynamic_property_key, DynamicAccessError, DynamicNameToken,
49};
50pub use error::{
51 expected_type_detail, invalid_argument_text, negative_page_bound_text,
52 uniqueness_violation_detail, ArgumentFault, ArithmeticFailure, CapacityKind, Error, Result,
53 NEGATIVE_PAGE_BOUND_DETAIL,
54};
55pub use error_kinds::{
56 duplicate_variable_detail, undefined_variable_detail, unknown_function_detail, ErrorKind,
57 TckErrorClass,
58};
59pub use literal::{LiteralValueKind, TOSTRING_TYPE_ERROR_DETAIL};
60pub use load_pool::{
61 current_load_threads, record_transient_lease, resolve_load_threads, run_load_tasks,
62 with_load_scope, LoadThreads, OpenTransientTracker, TransientLease,
63};
64pub use memory_limit::{
65 parse_expression_memory_limit, parse_memory_limit, parse_positive_memory_limit,
66 require_positive_memory_limit,
67};
68pub use namespace::{
69 is_graph_selector_function_name, node_element_id, parse_node_element_id, parse_rel_element_id,
70 rel_element_id, ElementIdRef, Namespace, GRAPH_SELECTOR_FUNCTIONS,
71 GRAPH_SELECTOR_FUNCTION_NAMES,
72};
73pub use output_safety::is_unsafe_output_char;
74pub use presence_bits::PresenceBits;
75pub use preview::{
76 preview_feature_disabled_text, DetectorKind, GateSite, ParseOption, PreviewFeature,
77 PreviewFeatures, PREVIEW_FEATURES,
78};
79pub use temporal::{QueryClockGuard, Temporal, TransactionClock};
80pub use tokens::{ExecutionReceipt, TokenEstimate, TokenOutcome};
81pub use traversal::{
82 require_traversal_depth, traversal_depth_exceeded_message, MAX_TRAVERSAL_DEPTH,
83 MAX_TRAVERSAL_DEPTH_CEILING,
84};
85pub use typename::{bare_type_name, expected_value_type_detail, value_type_name};
86pub use value::{
87 bytes_logical_bytes, logical_bytes_within, logical_bytes_within_memo, next_depth,
88 point_component, str_logical_bytes, tagged_str, uuid_hyphenated, uuid_parse,
89 value_depth_exceeded, ExpansionMemo, Node, Path, PointValue, PropertyMap, Relationship,
90 TaggedStr, Value, VectorCoordKind, MAX_VALUE_DEPTH,
91};
92
93pub type NodeId = i64;
94pub type RelId = i64;
95
96pub const fn is_virtual_id(id: i64) -> bool {
101 id < 0
102}
103
104pub fn validate_persisted_id(id: i64, what: &str) -> Result<()> {
111 if id < 0 || id == i64::MAX {
112 return Err(Error::storage(format!(
113 "{what} ID {id} is outside 0..i64::MAX"
114 )));
115 }
116 Ok(())
117}
118
119#[cfg(test)]
120mod tests {
121 use super::*;
122
123 #[test]
124 fn persisted_id_predicate_accepts_in_range_and_rejects_zero_nine_six() {
125 for id in [0, 1, 42, i64::MAX - 1] {
126 validate_persisted_id(id, "node").unwrap();
127 }
128 for id in [-1, i64::MIN, i64::MAX] {
129 let error = validate_persisted_id(id, "node").unwrap_err();
130 assert!(matches!(error, Error::Storage(_)), "{error}");
131 assert_eq!(
132 error.to_string(),
133 format!("storage error: node ID {id} is outside 0..i64::MAX")
134 );
135 }
136 }
137}