1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/******************************************************************************************
📍 منصة تحليل الأمان الجغرافي MKT KSA – تطوير منصور بن خالد
* 📄 رخصة Apache 2.0 – يسمح بالاستخدام والتعديل بشرط النسبة وعدم تقديم ضمانات.
* MKT KSA Geolocation Security – Developed by Mansour Bin Khalid (KSA 🇸🇦)
* Licensed under Apache 2.0 – https://www.apache.org/licenses/LICENSE-2.0
* © 2025 All rights reserved.
File Name: models.rs
Path: src/db/models.rs
File Role:
يحتوي هذا الملف على تعريفات هياكل البيانات (structs) التي تمثل الجداول
في قاعدة البيانات. تعمل هذه النماذج كوسيط بين كود Rust وقاعدة بيانات PostgreSQL،
مما يسمح بقراءة وكتابة البيانات بشكل آمن ومنظم باستخدام `sqlx`.
Main Tasks:
1. تعريف نماذج البيانات للجداول الرئيسية (Device, LocationRecord, etc.).
2. استخدام `derive macros` من `sqlx` و`serde` للربط التلقائي.
3. توثيق كل حقل لضمان وضوح مخطط قاعدة البيانات.
--------------------------------------------------------------
File Name: models.rs
Path: src/db/models.rs
File Role:
This file contains the struct definitions that represent tables in the database.
These models act as an intermediary between the Rust code and the PostgreSQL database,
allowing for safe and structured data reading and writing using `sqlx`.
Main Tasks:
1. Define data models for the main tables (Device, LocationRecord, etc.).
2. Use `derive macros` from `sqlx` and `serde` for automatic binding.
3. Document each field to ensure clarity of the database schema.
******************************************************************************************/
use ;
// ===================== نماذج البيانات الأساسية =====================
// ===================== Core Data Models =====================
/// Arabic: يمثل مستخدمًا مسجلاً في النظام. هذا النموذج هو حجر الأساس للمصادقة والصلاحيات.
///
/// English: Represents a registered user in the system. This model is the cornerstone of authentication and authorization.
/// Arabic: يمثل جهازًا مسجلاً في النظام. كل جهاز له هوية فريدة خاصة به.
/// English: Represents a registered device in the system. Each device has its own unique identity.
/// Arabic: يمثل سجلاً لموقع جغرافي تم التحقق منه وتوقيعه.
/// هذا النموذج هو أساس "البصمة الوراثية للبيانات".
///
/// English: Represents a verified and signed geographic location record.
/// This model is the foundation of the "Data Genetic Fingerprint".
/// Arabic: يمثل حدثًا سلوكيًا تم تسجيله لأغراض التحليل والتدقيق.
/// English: Represents a behavioral event logged for analysis and auditing.
/// Arabic: يمثل تنبيهًا أمنيًا تم إطلاقه بواسطة النظام وتوقيعه.
/// التوقيع يثبت أن التنبيه صادر من نظامنا وليس تنبيهًا زائفًا تم حقنه.
///
/// English: Represents a security alert triggered and signed by the system.
/// The signature proves the alert originated from our system and is not a fake injected alert.
// Models are backend-agnostic and currently used by the hardened SQLite path.