Compare commits
7 Commits
LireCarteV
...
86f29c3169
Author | SHA1 | Date | |
---|---|---|---|
86f29c3169
|
|||
a0f35a6667
|
|||
d320bbcc1d
|
|||
84cd97bc5c
|
|||
5e5267210b
|
|||
a82e43ce7f
|
|||
699978ad5e
|
5
.ignore
5
.ignore
@ -1,5 +0,0 @@
|
|||||||
# Ignorer les fichiers dont ne dépent pas la compilation
|
|
||||||
*.md
|
|
||||||
tailwind.config.js
|
|
||||||
*.example
|
|
||||||
scripts
|
|
1487
Cargo.lock
generated
1487
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
15
README.md
15
README.md
@ -17,7 +17,7 @@ Logiciel de Pharmacie libre et open-source.
|
|||||||
La CLI Tauri est nécessaire au lancement du client `desktop`. Elle peut être installée via Cargo :
|
La CLI Tauri est nécessaire au lancement du client `desktop`. Elle peut être installée via Cargo :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install tauri-cli --version "^2.0.0-beta"
|
cargo install tauri-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Tailwindcss CLI
|
#### Tailwindcss CLI
|
||||||
@ -47,19 +47,6 @@ Si vous souhaitez lancer les composants séparément, les indications de lanceme
|
|||||||
- [app](crates/app/README.md)
|
- [app](crates/app/README.md)
|
||||||
- [sesam-vitale](crates/sesam-vitale/README.md)
|
- [sesam-vitale](crates/sesam-vitale/README.md)
|
||||||
|
|
||||||
## Rechargement automatique
|
|
||||||
|
|
||||||
Pour permettre de développer plus rapidement, il existe une librairie qui recompile automatiquement nos modifications en cours : [`cargo-watch`](https://github.com/watchexec/cargo-watch) permet de relancer une commande `cargo` lorsqu'un fichier est modifié (example: `cargo run` --> `cargo watch -x run`).
|
|
||||||
|
|
||||||
Voici la commande pour l'installer dans un _package_ :
|
|
||||||
```bash
|
|
||||||
cargo add cargo-watch --dev --package app
|
|
||||||
```
|
|
||||||
|
|
||||||
Le fichier [`.ignore`](./ignore) permet d'ignorer certains fichiers pour éviter de relancer la recompilation inutilement.
|
|
||||||
|
|
||||||
⚠️ La librairie n'est pas compatible avec _Windows 7_ et les versions antérieurs de _Windows_.
|
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
Packager le client desktop
|
Packager le client desktop
|
||||||
|
@ -7,13 +7,7 @@ edition = "2021"
|
|||||||
askama = "0.12.1"
|
askama = "0.12.1"
|
||||||
askama_axum = "0.4.0"
|
askama_axum = "0.4.0"
|
||||||
axum = "0.7.5"
|
axum = "0.7.5"
|
||||||
listenfd = "1.0.1"
|
|
||||||
notify = "6.1.1"
|
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread"] }
|
||||||
tower-http = { version = "0.5.2", features = ["fs"] }
|
tower-http = { version = "0.5.2", features = ["fs"] }
|
||||||
tower-livereload = "0.9.3"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
cargo-watch = "8.5.1"
|
|
||||||
systemfd = "0.4.0"
|
|
||||||
|
@ -13,23 +13,3 @@
|
|||||||
```bash
|
```bash
|
||||||
cargo run --bin app
|
cargo run --bin app
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rechargement automatique (_auto-reload_)
|
|
||||||
|
|
||||||
Pour le projet `app`, nous utilisons en plus de `cargo-watch` ses librairies :
|
|
||||||
- [`systemfd`](https://github.com/mitsuhiko/systemfd) permet de redémarrer un serveur sans interrompre les connexions en cours, il transmet le descripteur de fichier du socket à une nouvelle instance du serveur (exemple: `cargo watch -x run` --> `systemfd --no-pid -s http::3000 -- cargo watch -x run`). Si le port est déjà pris il en prendra un autre.
|
|
||||||
- [`listenfd`](https://github.com/mitsuhiko/listenfd) permet, côté _Rust_, de démarrer un serveur en utilisant des connexions déjà ouvertes.
|
|
||||||
|
|
||||||
Pour notre application voici la commande à lancer :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
systemfd --no-pid -s http::3000 -- cargo watch -x 'run --bin app'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Chargement à chaud (_livereload_)
|
|
||||||
|
|
||||||
Pour que notre navigateur rafraîchisse automatique notre page lorsque le serveur a été recompilé, nous utilisons la librairie [`tower-livereload`](https://github.com/leotaku/tower-livereload).
|
|
||||||
|
|
||||||
A chaque changement, que ça soit sur du code en _Rust_, _HTML_, _CSS_ ou _JS_ alors le navigateur va recharger entièrement la page.
|
|
||||||
|
|
||||||
En Rust, il n'existe pas encore d'outil de _Hot Reload_ complet et intégré comme on en trouve dans d'autres environnements de développement web, comme pour _Node.js_.
|
|
||||||
|
1
crates/app/assets/css/flowbite@2.5.1.min.css
vendored
1
crates/app/assets/css/flowbite@2.5.1.min.css
vendored
File diff suppressed because one or more lines are too long
@ -615,30 +615,6 @@ video {
|
|||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mb-4 {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mt-4 {
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mt-6 {
|
|
||||||
margin-top: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mb-2 {
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mb-2\.5 {
|
|
||||||
margin-bottom: 0.625rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.me-3 {
|
|
||||||
margin-inline-end: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
@ -651,10 +627,6 @@ video {
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid {
|
|
||||||
display: grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -679,38 +651,6 @@ video {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.h-32 {
|
|
||||||
height: 8rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-48 {
|
|
||||||
height: 12rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-96 {
|
|
||||||
height: 24rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-2\.5 {
|
|
||||||
height: 0.625rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-9 {
|
|
||||||
height: 2.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-7 {
|
|
||||||
height: 1.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-2 {
|
|
||||||
height: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-4 {
|
|
||||||
height: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.min-h-full {
|
.min-h-full {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
@ -735,22 +675,6 @@ video {
|
|||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.w-32 {
|
|
||||||
width: 8rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-20 {
|
|
||||||
width: 5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-24 {
|
|
||||||
width: 6rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-28 {
|
|
||||||
width: 7rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.max-w-7xl {
|
.max-w-7xl {
|
||||||
max-width: 80rem;
|
max-width: 80rem;
|
||||||
}
|
}
|
||||||
@ -759,10 +683,6 @@ video {
|
|||||||
max-width: 20rem;
|
max-width: 20rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.max-w-sm {
|
|
||||||
max-width: 24rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-shrink-0 {
|
.flex-shrink-0 {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
@ -771,24 +691,6 @@ video {
|
|||||||
transform-origin: top right;
|
transform-origin: top right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse {
|
|
||||||
50% {
|
|
||||||
opacity: .5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.animate-pulse {
|
|
||||||
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid-cols-1 {
|
|
||||||
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid-cols-2 {
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.items-center {
|
.items-center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@ -801,10 +703,6 @@ video {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gap-4 {
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.space-y-1 > :not([hidden]) ~ :not([hidden]) {
|
.space-y-1 > :not([hidden]) ~ :not([hidden]) {
|
||||||
--tw-space-y-reverse: 0;
|
--tw-space-y-reverse: 0;
|
||||||
margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
|
margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
|
||||||
@ -819,22 +717,6 @@ video {
|
|||||||
border-radius: 0.375rem;
|
border-radius: 0.375rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rounded-lg {
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rounded {
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-2 {
|
|
||||||
border-width: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border {
|
|
||||||
border-width: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-b {
|
.border-b {
|
||||||
border-bottom-width: 1px;
|
border-bottom-width: 1px;
|
||||||
}
|
}
|
||||||
@ -843,35 +725,16 @@ video {
|
|||||||
border-top-width: 1px;
|
border-top-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-dashed {
|
|
||||||
border-style: dashed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-gray-200 {
|
.border-gray-200 {
|
||||||
--tw-border-opacity: 1;
|
--tw-border-opacity: 1;
|
||||||
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-gray-300 {
|
|
||||||
--tw-border-opacity: 1;
|
|
||||||
border-color: rgb(209 213 219 / var(--tw-border-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-white {
|
.bg-white {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-gray-200 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(229 231 235 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-gray-300 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(209 213 219 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.p-1 {
|
.p-1 {
|
||||||
padding: 0.25rem;
|
padding: 0.25rem;
|
||||||
}
|
}
|
||||||
@ -880,10 +743,6 @@ video {
|
|||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-4 {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.px-4 {
|
.px-4 {
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
@ -967,27 +826,12 @@ video {
|
|||||||
color: rgb(17 24 39 / var(--tw-text-opacity));
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.text-gray-200 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(229 231 235 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.opacity-0 {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shadow-lg {
|
.shadow-lg {
|
||||||
--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
||||||
--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
|
--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
|
||||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.shadow {
|
|
||||||
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
||||||
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
|
||||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ring-1 {
|
.ring-1 {
|
||||||
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
||||||
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
||||||
@ -1051,10 +895,6 @@ video {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sm\:grid-cols-2 {
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.sm\:items-center {
|
.sm\:items-center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@ -1071,20 +911,6 @@ video {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.md\:h-64 {
|
|
||||||
height: 16rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md\:h-72 {
|
|
||||||
height: 18rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.md\:p-6 {
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
.lg\:block {
|
.lg\:block {
|
||||||
display: block;
|
display: block;
|
||||||
@ -1094,39 +920,8 @@ video {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lg\:grid-cols-4 {
|
|
||||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.lg\:px-8 {
|
.lg\:px-8 {
|
||||||
padding-left: 2rem;
|
padding-left: 2rem;
|
||||||
padding-right: 2rem;
|
padding-right: 2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
.dark\:border-gray-600 {
|
|
||||||
--tw-border-opacity: 1;
|
|
||||||
border-color: rgb(75 85 99 / var(--tw-border-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark\:border-gray-700 {
|
|
||||||
--tw-border-opacity: 1;
|
|
||||||
border-color: rgb(55 65 81 / var(--tw-border-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark\:bg-gray-700 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark\:text-gray-600 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(75 85 99 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark\:text-gray-700 {
|
|
||||||
--tw-text-opacity: 1;
|
|
||||||
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
5
crates/app/assets/js/alpinejs@3.14.1.min.js
vendored
5
crates/app/assets/js/alpinejs@3.14.1.min.js
vendored
File diff suppressed because one or more lines are too long
2
crates/app/assets/js/flowbite@2.5.1.min.js
vendored
2
crates/app/assets/js/flowbite@2.5.1.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,9 +1,9 @@
|
|||||||
mod pages;
|
|
||||||
mod templates;
|
mod templates;
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use askama_axum::Template;
|
use askama::Template;
|
||||||
|
use askama_axum::IntoResponse;
|
||||||
use axum::http::{StatusCode, Uri};
|
use axum::http::{StatusCode, Uri};
|
||||||
use tower_http::services::ServeDir;
|
use tower_http::services::ServeDir;
|
||||||
|
|
||||||
@ -13,17 +13,16 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
|
|||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "index.html")]
|
#[template(path = "index.html")]
|
||||||
pub struct GetIndexTemplate;
|
pub struct GetIndexResponse;
|
||||||
|
|
||||||
async fn root() -> GetIndexTemplate {
|
async fn root() -> impl IntoResponse {
|
||||||
GetIndexTemplate {}
|
GetIndexResponse {}.into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_router(assets_path: &Path) -> axum::Router {
|
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.nest_service("/assets", ServeDir::new(assets_path))
|
.nest_service("/assets", ServeDir::new(assets_path))
|
||||||
.route("/", axum::routing::get(root))
|
.route("/", axum::routing::get(root))
|
||||||
.nest("/pages", pages::get_routes())
|
|
||||||
.merge(templates::get_routes())
|
.merge(templates::get_routes())
|
||||||
.fallback(fallback)
|
.fallback(fallback)
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,15 @@
|
|||||||
use ::app::get_router;
|
use ::app::get_router;
|
||||||
use axum::body::Body;
|
|
||||||
use axum::http::Request;
|
|
||||||
use listenfd::ListenFd;
|
|
||||||
use notify::Watcher;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tokio::net::TcpListener;
|
|
||||||
use tower_livereload::predicate::Predicate;
|
|
||||||
use tower_livereload::LiveReloadLayer;
|
|
||||||
|
|
||||||
/// Nous filtrons les requêtes de `htmx` pour ne pas inclure le script _JS_ qui gère le rechargement
|
|
||||||
/// Voir https://github.com/leotaku/tower-livereload/pull/3
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
struct NotHtmxPredicate;
|
|
||||||
impl<T> Predicate<Request<T>> for NotHtmxPredicate {
|
|
||||||
fn check(&mut self, req: &Request<T>) -> bool {
|
|
||||||
!(req.headers().contains_key("hx-request"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEFAULT_LISTENER: &str = "localhost:3000";
|
|
||||||
async fn get_tcp_listener() -> TcpListener {
|
|
||||||
let mut listenfd = ListenFd::from_env();
|
|
||||||
|
|
||||||
match listenfd.take_tcp_listener(0).unwrap() {
|
|
||||||
// if we are given a tcp listener on listen fd 0, we use that one
|
|
||||||
Some(listener) => {
|
|
||||||
listener.set_nonblocking(true).unwrap();
|
|
||||||
TcpListener::from_std(listener).unwrap()
|
|
||||||
}
|
|
||||||
// otherwise fall back to local listening
|
|
||||||
None => TcpListener::bind(DEFAULT_LISTENER).await.unwrap(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_livereload_layer(templates_path: &Path) -> LiveReloadLayer<NotHtmxPredicate> {
|
|
||||||
let livereload = LiveReloadLayer::new();
|
|
||||||
let reloader = livereload.reloader();
|
|
||||||
let mut watcher = notify::recommended_watcher(move |_| reloader.reload()).unwrap();
|
|
||||||
watcher
|
|
||||||
.watch(templates_path, notify::RecursiveMode::Recursive)
|
|
||||||
.unwrap();
|
|
||||||
livereload.request_predicate::<Body, NotHtmxPredicate>(NotHtmxPredicate)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
let assets_path = Path::new(&manifest_dir).join("assets");
|
let assets_path = Path::new(&manifest_dir).join("assets");
|
||||||
let templates_path = Path::new(&manifest_dir).join("templates");
|
let router = get_router(assets_path.as_path());
|
||||||
|
|
||||||
let livereload_layer = get_livereload_layer(&templates_path);
|
// TODO: select port based on available port (or ask in CLI)
|
||||||
let router = get_router(assets_path.as_path()).layer(livereload_layer);
|
let listener = tokio::net::TcpListener::bind("localhost:3000").await.unwrap();
|
||||||
|
|
||||||
let listener: TcpListener = get_tcp_listener().await;
|
|
||||||
println!("Listening on: http://{}", listener.local_addr().unwrap());
|
println!("Listening on: http://{}", listener.local_addr().unwrap());
|
||||||
|
axum::serve(listener, router).await.unwrap();
|
||||||
// Run the server with the router
|
|
||||||
axum::serve(listener, router.into_make_service())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
use askama_axum::Template;
|
|
||||||
|
|
||||||
#[derive(Template)]
|
|
||||||
#[template(path = "pages/cps.html")]
|
|
||||||
pub struct CpsTemplate;
|
|
||||||
|
|
||||||
pub async fn cps() -> CpsTemplate {
|
|
||||||
CpsTemplate
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
use askama_axum::Template;
|
|
||||||
|
|
||||||
#[derive(Template)]
|
|
||||||
#[template(path = "pages/home.html")]
|
|
||||||
pub struct HomeTemplate;
|
|
||||||
|
|
||||||
pub async fn home() -> HomeTemplate {
|
|
||||||
HomeTemplate
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
use axum::{routing, Router};
|
|
||||||
|
|
||||||
mod cps;
|
|
||||||
mod home;
|
|
||||||
|
|
||||||
pub fn get_routes() -> Router {
|
|
||||||
Router::new()
|
|
||||||
.route("/home", routing::get(home::home))
|
|
||||||
.route("/cps", routing::get(cps::cps))
|
|
||||||
}
|
|
@ -1,18 +1,20 @@
|
|||||||
use askama_axum::Template;
|
use askama::Template;
|
||||||
|
use askama_axum::IntoResponse;
|
||||||
use axum::{routing, Router};
|
use axum::{routing, Router};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "hello.html")]
|
#[template(path = "hello.html")]
|
||||||
struct HelloTemplate {
|
struct HelloResponse {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn hello() -> HelloTemplate {
|
async fn hello() -> impl IntoResponse {
|
||||||
HelloTemplate {
|
HelloResponse {
|
||||||
name: "Theo".to_string(),
|
name: "Theo".to_string(),
|
||||||
}
|
}.into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_routes() -> Router {
|
pub fn get_routes() -> Router {
|
||||||
Router::new().route("/", routing::get(hello))
|
Router::new()
|
||||||
|
.route("/", routing::get(hello))
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use askama_axum::Template;
|
use askama::Template;
|
||||||
|
use askama_axum::IntoResponse;
|
||||||
use axum::{extract::Query, routing, Router};
|
use axum::{extract::Query, routing, Router};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
struct MenuItem {
|
struct MenuItem {
|
||||||
label: String,
|
label: String,
|
||||||
href: String,
|
id: String,
|
||||||
current: bool,
|
current: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,18 +16,16 @@ struct MenuParameters {
|
|||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "layout/nav/nav-menu-items.html")]
|
#[template(path = "layout/nav/nav-menu-items.html")]
|
||||||
struct MenuTemplate {
|
struct MenuResponse {
|
||||||
mobile: bool,
|
mobile: bool,
|
||||||
items: Vec<MenuItem>,
|
items: Vec<MenuItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuTemplate {
|
impl MenuResponse {
|
||||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||||
let common_classes = match self.mobile {
|
let common_classes = match self.mobile {
|
||||||
true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(),
|
true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(),
|
||||||
false => {
|
false => "inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string(),
|
||||||
"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
match (self.mobile, is_current_item) {
|
match (self.mobile, is_current_item) {
|
||||||
(true, true) => common_classes + " border-indigo-500 bg-indigo-50 text-indigo-700",
|
(true, true) => common_classes + " border-indigo-500 bg-indigo-50 text-indigo-700",
|
||||||
@ -37,24 +36,30 @@ impl MenuTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||||
MenuTemplate {
|
MenuResponse {
|
||||||
mobile: params.mobile,
|
mobile: params.mobile,
|
||||||
items: vec![
|
items: vec![
|
||||||
MenuItem {
|
MenuItem {
|
||||||
label: "Accueil".to_string(),
|
label: "Accueil".to_string(),
|
||||||
href: "/pages/home".to_string(),
|
id: "home".to_string(),
|
||||||
current: true,
|
current: true,
|
||||||
},
|
},
|
||||||
MenuItem {
|
MenuItem {
|
||||||
label: "CPS".to_string(),
|
label: "À propos".to_string(),
|
||||||
href: "/pages/cps".to_string(),
|
id: "about".to_string(),
|
||||||
current: false,
|
current: false,
|
||||||
},
|
},
|
||||||
],
|
MenuItem {
|
||||||
}
|
label: "Contact".to_string(),
|
||||||
|
id: "contact".to_string(),
|
||||||
|
current: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}.into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_routes() -> Router {
|
pub fn get_routes() -> Router {
|
||||||
Router::new().route("/menu", routing::get(menu))
|
Router::new()
|
||||||
|
.route("/menu", routing::get(menu))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use askama_axum::Template;
|
use askama::Template;
|
||||||
|
use askama_axum::IntoResponse;
|
||||||
use axum::{extract::Query, routing, Router};
|
use axum::{extract::Query, routing, Router};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
@ -15,12 +16,12 @@ struct MenuParameters {
|
|||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "layout/nav/profile-menu-items.html")]
|
#[template(path = "layout/nav/profile-menu-items.html")]
|
||||||
struct MenuTemplate {
|
struct MenuResponse {
|
||||||
mobile: bool,
|
mobile: bool,
|
||||||
items: Vec<MenuItem>,
|
items: Vec<MenuItem>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MenuTemplate {
|
impl MenuResponse {
|
||||||
fn get_classes(&self, is_current_item: &bool) -> String {
|
fn get_classes(&self, is_current_item: &bool) -> String {
|
||||||
let common_classes = match self.mobile {
|
let common_classes = match self.mobile {
|
||||||
true => "block px-4 py-2 text-base font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-800".to_string(),
|
true => "block px-4 py-2 text-base font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-800".to_string(),
|
||||||
@ -35,8 +36,8 @@ impl MenuTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
|
||||||
MenuTemplate {
|
MenuResponse {
|
||||||
mobile: params.mobile,
|
mobile: params.mobile,
|
||||||
items: vec![
|
items: vec![
|
||||||
MenuItem {
|
MenuItem {
|
||||||
@ -55,9 +56,10 @@ async fn menu(Query(params): Query<MenuParameters>) -> MenuTemplate {
|
|||||||
current: false,
|
current: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}.into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_routes() -> Router {
|
pub fn get_routes() -> Router {
|
||||||
Router::new().route("/menu", routing::get(menu))
|
Router::new()
|
||||||
}
|
.route("/menu", routing::get(menu))
|
||||||
|
}
|
@ -3,11 +3,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>{% block title %}{{ title }}{% endblock %}</title>
|
<title>{% block title %}{{ title }}{% endblock %}</title>
|
||||||
|
|
||||||
<script src="/assets/js/htmx@2.0.1.min.js"></script>
|
<script src="/assets/js/htmx.min.js"></script>
|
||||||
<script src="/assets/js/alpinejs@3.14.1.min.js" defer></script>
|
<script src="//unpkg.com/alpinejs" defer></script>
|
||||||
<link href="/assets/css/style.css" rel="stylesheet">
|
<link href="/assets/css/style.css" rel="stylesheet">
|
||||||
<link href="/assets/css/flowbite@2.5.1.min.css" rel="stylesheet" />
|
|
||||||
<script src="/assets/js/flowbite@2.5.1.min.js"></script>
|
|
||||||
|
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
@ -6,27 +6,20 @@
|
|||||||
<div class="py-10">
|
<div class="py-10">
|
||||||
<header>
|
<header>
|
||||||
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||||
<h1
|
<h1 class="text-3xl font-bold leading-tight tracking-tight text-gray-900">Dashboard</h1>
|
||||||
id="page-title"
|
|
||||||
class="text-3xl font-bold leading-tight tracking-tight text-gray-900"
|
|
||||||
>
|
|
||||||
{% include "skeletons/page-title.html" %}
|
|
||||||
</h1>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<div
|
<div class="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
|
||||||
id="main-container"
|
|
||||||
class="mx-auto max-w-7xl px-4 py-8 sm:px-6 lg:px-8"
|
|
||||||
>
|
|
||||||
<!-- Your content -->
|
<!-- Your content -->
|
||||||
<div
|
<div
|
||||||
hx-get="/pages/home"
|
id="hello"
|
||||||
|
hx-get="/hello"
|
||||||
hx-target="this"
|
hx-target="this"
|
||||||
hx-trigger="load"
|
hx-trigger="load"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
{% include "skeletons/card.html" %}
|
Chargement ...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
hx-trigger="load"
|
hx-trigger="load"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
{% include "skeletons/menu-items.html" %}
|
Chargement ...
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
<a
|
<a
|
||||||
href=""
|
href="#{{ item.id }}"
|
||||||
hx-get="{{ item.href }}"
|
|
||||||
hx-trigger="click"
|
|
||||||
hx-target="#main-container"
|
|
||||||
hx-swap="innerHTML"
|
|
||||||
class="{{ Self::get_classes(self, item.current) }}"
|
class="{{ Self::get_classes(self, item.current) }}"
|
||||||
aria-current="{% if item.current %}page{% endif %}"
|
aria-current="{% if item.current %}page{% endif %}"
|
||||||
>
|
>
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
<h3 id="page-title" hx-swap-oob="textContent">
|
|
||||||
CPS
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed border-gray-300 rounded-lg dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-96 mb-4"
|
|
||||||
></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-96 mb-4"
|
|
||||||
></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
@ -1,52 +0,0 @@
|
|||||||
<h3 id="page-title" hx-swap-oob="textContent">
|
|
||||||
Accueil
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed border-gray-300 rounded-lg dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-32 md:h-64"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-96 mb-4"
|
|
||||||
></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-96 mb-4"
|
|
||||||
></div>
|
|
||||||
<div class="grid grid-cols-2 gap-4">
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
<div
|
|
||||||
class="border-2 border-dashed rounded-lg border-gray-300 dark:border-gray-600 h-48 md:h-72"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
@ -1,22 +0,0 @@
|
|||||||
<div role="status" class="animate-pulse max-w-sm p-4 border border-gray-200 rounded shadow md:p-6 dark:border-gray-700">
|
|
||||||
<div class="flex items-center justify-center h-48 mb-4 bg-gray-300 rounded dark:bg-gray-700">
|
|
||||||
<svg class="w-10 h-10 text-gray-200 dark:text-gray-600" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 16 20">
|
|
||||||
<path d="M14.066 0H7v5a2 2 0 0 1-2 2H0v11a1.97 1.97 0 0 0 1.934 2h12.132A1.97 1.97 0 0 0 16 18V2a1.97 1.97 0 0 0-1.934-2ZM10.5 6a1.5 1.5 0 1 1 0 2.999A1.5 1.5 0 0 1 10.5 6Zm2.221 10.515a1 1 0 0 1-.858.485h-8a1 1 0 0 1-.9-1.43L5.6 10.039a.978.978 0 0 1 .936-.57 1 1 0 0 1 .9.632l1.181 2.981.541-1a.945.945 0 0 1 .883-.522 1 1 0 0 1 .879.529l1.832 3.438a1 1 0 0 1-.031.988Z"/>
|
|
||||||
<path d="M5 5V.13a2.96 2.96 0 0 0-1.293.749L.879 3.707A2.98 2.98 0 0 0 .13 5H5Z"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
|
|
||||||
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
|
|
||||||
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"></div>
|
|
||||||
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
||||||
<div class="flex items-center mt-4">
|
|
||||||
<svg class="w-10 h-10 me-3 text-gray-200 dark:text-gray-700" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
|
||||||
<path d="M10 0a10 10 0 1 0 10 10A10.011 10.011 0 0 0 10 0Zm0 5a3 3 0 1 1 0 6 3 3 0 0 1 0-6Zm0 13a8.949 8.949 0 0 1-4.951-1.488A3.987 3.987 0 0 1 9 13h2a3.987 3.987 0 0 1 3.951 3.512A8.949 8.949 0 0 1 10 18Z"/>
|
|
||||||
</svg>
|
|
||||||
<div>
|
|
||||||
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-32 mb-2"></div>
|
|
||||||
<div class="w-48 h-2 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span class="sr-only">Loading...</span>
|
|
||||||
</div>
|
|
@ -1,4 +0,0 @@
|
|||||||
<div role="status" class="animate-pulse flex items-center justify-center h-full">
|
|
||||||
<div class="w-32 h-4 bg-gray-200 rounded-full dark:bg-gray-700 me-3"></div>
|
|
||||||
<div class="w-32 h-4 bg-gray-200 rounded-full dark:bg-gray-700"></div>
|
|
||||||
</div>
|
|
@ -1 +0,0 @@
|
|||||||
<div role="status" class="animate-pulse h-7 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mt-3"></div>
|
|
@ -1,3 +0,0 @@
|
|||||||
SESAM_FSV_VERSION=1.40.14
|
|
||||||
SESAM_FSV_LIB_PATH="C:/Program Files/santesocial/fsv/${SESAM_FSV_VERSION}/lib"
|
|
||||||
SESAM_FSV_SSVLIB=ssvw64
|
|
@ -1,2 +0,0 @@
|
|||||||
SESAM_FSV_VERSION=1.40.14
|
|
||||||
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
|
@ -1,2 +1,2 @@
|
|||||||
SESAM_FSV_VERSION=1.40.13
|
SESAM_FSV_VERSION=1.40.13
|
||||||
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
SESAM_INI_PATH=${ALLUSERSPROFILE}\\santesocial\\fsv\\${SESAM_FSV_VERSION}\\conf\\sesam.ini
|
@ -16,10 +16,7 @@ fn main() {
|
|||||||
|
|
||||||
// Add local lib directory to the linker search path (for def files and static libs)
|
// Add local lib directory to the linker search path (for def files and static libs)
|
||||||
let static_lib_path = manifest_path.join("lib");
|
let static_lib_path = manifest_path.join("lib");
|
||||||
println!(
|
println!("cargo::rustc-link-search=native={}", static_lib_path.display());
|
||||||
"cargo::rustc-link-search=native={}",
|
|
||||||
static_lib_path.display()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the SESAM_FSV_LIB_PATH to the linker search path
|
// Add the SESAM_FSV_LIB_PATH to the linker search path
|
||||||
let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap());
|
let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap());
|
||||||
@ -34,9 +31,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Link the SESAM_FSV_SSVLIB dynamic library
|
// Link the SESAM_FSV_SSVLIB dynamic library
|
||||||
println!(
|
println!("cargo::rustc-link-lib=dylib={}", env::var("SESAM_FSV_SSVLIB").unwrap());
|
||||||
"cargo::rustc-link-lib=dylib={}",
|
|
||||||
env::var("SESAM_FSV_SSVLIB").unwrap()
|
|
||||||
);
|
|
||||||
// TODO : try `raw-dylib` instead of `dylib` on Windows to avoid the need of the `lib` headers compiled from the `def`
|
// TODO : try `raw-dylib` instead of `dylib` on Windows to avoid the need of the `lib` headers compiled from the `def`
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -1,876 +0,0 @@
|
|||||||
use libc::{c_void, size_t};
|
|
||||||
use std::ffi::CString;
|
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
use crate::libssv::SSV_LireDroitsVitale;
|
|
||||||
|
|
||||||
use crate::ssv_memory::{decode_ssv_memory, Block};
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub struct CarteVitale {
|
|
||||||
donneesAssure: DonneesAssure,
|
|
||||||
serviceAMOFamille: ServiceAMOFamille,
|
|
||||||
donneesAccidentTravail: DonneesAccidentTravail,
|
|
||||||
donneesBeneficiaire: Vec<DonneesBeneficiaire>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. CB = Caractères Binaires »
|
|
||||||
// 2. CE = Caractères « Etendus » (ISO 8859-1)
|
|
||||||
// 3. CA = Caractères Alphanumériques (ASCII?)
|
|
||||||
// 4. CN = Caractères Numériques
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesAssure {
|
|
||||||
type_de_carte_vitale: char, // CA
|
|
||||||
numero_de_serie: String, // CN - 1 -> 20
|
|
||||||
date_de_fin_de_validite: String, // CN - Format AAAAMMJJ0000
|
|
||||||
donnees_administration_ruf1: char, // CN
|
|
||||||
donnees_administration_ruf2: String, // CA - 24
|
|
||||||
donnees_ruf_administration: String, // CE - 10
|
|
||||||
type_d_identification_du_porteur: char, // CA
|
|
||||||
numero_national_d_immatriculation: String, // CA - 13
|
|
||||||
cle_du_nir: String, // CA - 2
|
|
||||||
code_regime: String, // CN - 2
|
|
||||||
caisse_gestionnaire: String, // CN - 3
|
|
||||||
centre_gestionnaire: String, // CN - 4
|
|
||||||
code_gestion: String, // CA - 2
|
|
||||||
donnees_ruf_famille: String, // CE - 55
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct ServiceAMOFamille {
|
|
||||||
code_service_amo_famille: String, // CN - 2
|
|
||||||
date_de_debut_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_service_amo_famille: String, // CN - Format AAAAMMJJ0000
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesAccidentTravail {
|
|
||||||
organisme_gestionnaire_risque_at: String, // CN - 9
|
|
||||||
code_at: char, // CA - 2
|
|
||||||
identifiant_at: String, // CN - 9
|
|
||||||
organisme_gestionnaire_at1: String, // CN - 9
|
|
||||||
code_at1: char, // CA - 2
|
|
||||||
identifiant_at1: String, // CN - 9
|
|
||||||
organisme_gestionnaire_at2: String, // CN - 9
|
|
||||||
code_at2: char, // CA - 2
|
|
||||||
identifiant_at2: String, // CN - 9
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesBeneficiaire {
|
|
||||||
nom_usuel: String, // CE - 27
|
|
||||||
nom_de_famille: String, // CE - 27
|
|
||||||
prenom: String, // CE - 27
|
|
||||||
adresse_ligne_1: String, // CE - 32
|
|
||||||
adresse_ligne_2: String, // CE - 32
|
|
||||||
adresse_ligne_3: String, // CE - 32
|
|
||||||
adresse_ligne_4: String, // CE - 32
|
|
||||||
adresse_ligne_5: String, // CE - 32
|
|
||||||
nir_certifie: String, // CA - 13
|
|
||||||
cle_du_nir_certifie: String, // CN - 2
|
|
||||||
date_de_certification_du_nir: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_naissance: String, // CN - Format AAAAMMJJ0000
|
|
||||||
rang_de_naissance: String, // CN - 1
|
|
||||||
qualite: String, // CN - 2
|
|
||||||
code_service_amo_beneficiaire: char, // CA - 2
|
|
||||||
date_de_debut_service_amo: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_service_amo: String, // CN - Format AAAAMMJJ0000
|
|
||||||
donnees_ruf_amo: String, // CE - 30
|
|
||||||
periodeDroitsAMO: Vec<PeriodeDroitsAMO>,
|
|
||||||
periodeCodeCouverture: Vec<PeriodeCodeCouverture>,
|
|
||||||
donneesMutuelle: DonneesMutuelle,
|
|
||||||
donneesComplementaire: DonneesComplementaire,
|
|
||||||
donneesRUFBeneficiaireComplementaire: DonneesRUFBeneficiaireComplementaire,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct PeriodeDroitsAMO {
|
|
||||||
date_de_debut_droits_amo: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_droits_amo: String, // CN - Format AAAAMMJJ0000
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct PeriodeCodeCouverture {
|
|
||||||
date_de_debut_code_couverture: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_code_couverture: String, // CN - Format AAAAMMJJ0000
|
|
||||||
code_ald: String, // CN - 1
|
|
||||||
code_situation: String, // CN - 4
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesMutuelle {
|
|
||||||
identification_mutuelle: String, // CN - 8
|
|
||||||
garanties_effectives: String, // CA - 8
|
|
||||||
indicateur_de_traitement_mutuelle: String, // CN - 2
|
|
||||||
type_de_services_associes: char, // CA - 1
|
|
||||||
services_associes_au_contrat: String, // CA - 17
|
|
||||||
code_aiguillage_sts: char, // CA - 1
|
|
||||||
periodeDroitsMutuelle: Vec<PeriodeDroitsMutuelle>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct PeriodeDroitsMutuelle {
|
|
||||||
date_de_debut_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_droits_mutuelle: String, // CN - Format AAAAMMJJ0000
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesComplementaire {
|
|
||||||
numero_complementaire_b2: String, // CA - 10
|
|
||||||
numero_complementaire_edi: String, // CA - 19
|
|
||||||
numero_adherent_amc: String, // CA - 8
|
|
||||||
indicateur_de_traitement_amc: String, // CN - 2
|
|
||||||
date_de_debut_validite_amc: String, // CN - Format AAAAMMJJ0000
|
|
||||||
date_de_fin_validite_amc: String, // CN - Format AAAAMMJJ0000
|
|
||||||
code_routage_flux_amc: String, // CA - 2
|
|
||||||
identifiant_hote: String, // CA - 3
|
|
||||||
nom_de_domaine_amc: String, // CE - 20
|
|
||||||
code_aiguillage_sts: char, // CA - 1
|
|
||||||
type_de_services_associes: char, // CA - 1
|
|
||||||
services_associes_au_contrat: String, // CE - 17
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct DonneesRUFBeneficiaireComplementaire {
|
|
||||||
donnees_ruf_beneficiaire_complementaire: String, // CE - 115
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn LireDroitsVitale(
|
|
||||||
lecteurPS: &str,
|
|
||||||
lecteurVitale: &str,
|
|
||||||
codePorteurPS: &str,
|
|
||||||
dateConsultation: &str,
|
|
||||||
) -> Result<CarteVitale, String> {
|
|
||||||
let resource_ps = CString::new(lecteurPS).expect("CString::new failed");
|
|
||||||
let resource_vitale = CString::new(lecteurVitale).expect("CString::new failed");
|
|
||||||
let card_number = CString::new(codePorteurPS).expect("CString::new failed");
|
|
||||||
let date_consultation = CString::new(dateConsultation).expect("CString::new failed");
|
|
||||||
|
|
||||||
let mut buffer: *mut c_void = ptr::null_mut();
|
|
||||||
let mut size: size_t = 0;
|
|
||||||
let mut hex_values: &[u8] = &[];
|
|
||||||
unsafe {
|
|
||||||
let result = SSV_LireDroitsVitale(
|
|
||||||
resource_ps.as_ptr(),
|
|
||||||
resource_vitale.as_ptr(),
|
|
||||||
card_number.as_ptr(),
|
|
||||||
date_consultation.as_ptr(),
|
|
||||||
&mut buffer,
|
|
||||||
&mut size,
|
|
||||||
);
|
|
||||||
println!("SSV_LireDroitsVitale result: {}", result);
|
|
||||||
|
|
||||||
if !buffer.is_null() {
|
|
||||||
hex_values = std::slice::from_raw_parts(buffer as *const u8, size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let groups = decode_ssv_memory(hex_values, hex_values.len());
|
|
||||||
|
|
||||||
let OUT = decode_carte_vitale(groups);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
if !buffer.is_null() {
|
|
||||||
libc::free(buffer); // ??? si liberer avant decode_ssv_memory et decode_carte_vitale alors hex_values n'est plus correct ???
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OUT
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fn decode_carte_vitale(groups: Vec<Block>) -> Result<CarteVitale, String> {
|
|
||||||
let mut cartevitale = CarteVitale::default();
|
|
||||||
|
|
||||||
for group in groups {
|
|
||||||
for field in group.content {
|
|
||||||
match (group.id, field.id) {
|
|
||||||
(104, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.push(DonneesBeneficiaire::default());
|
|
||||||
}
|
|
||||||
(105, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeDroitsAMO
|
|
||||||
.push(PeriodeDroitsAMO::default());
|
|
||||||
}
|
|
||||||
(106, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeCodeCouverture
|
|
||||||
.push(PeriodeCodeCouverture::default());
|
|
||||||
}
|
|
||||||
(108, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.periodeDroitsMutuelle
|
|
||||||
.push(PeriodeDroitsMutuelle::default());
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
if field.content.len() > 0 {
|
|
||||||
match (group.id, field.id) {
|
|
||||||
(101, 1) => {
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAssure.type_de_carte_vitale = byte as char;
|
|
||||||
}
|
|
||||||
(101, 2) => {
|
|
||||||
cartevitale.donneesAssure.numero_de_serie = //bytes_to_decimal_string(&field.content);
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 3) => {
|
|
||||||
cartevitale.donneesAssure.date_de_fin_de_validite =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 4) => {
|
|
||||||
println!("101.4 field.size: {:#?}", field.size);
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAssure.donnees_administration_ruf1 = byte as char;
|
|
||||||
}
|
|
||||||
(101, 5) => {
|
|
||||||
cartevitale.donneesAssure.donnees_administration_ruf2 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 6) => {
|
|
||||||
cartevitale.donneesAssure.donnees_ruf_administration =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 7) => {
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAssure.type_d_identification_du_porteur = byte as char;
|
|
||||||
}
|
|
||||||
(101, 8) => {
|
|
||||||
cartevitale.donneesAssure.numero_national_d_immatriculation =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 9) => {
|
|
||||||
cartevitale.donneesAssure.cle_du_nir =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 10) => {
|
|
||||||
cartevitale.donneesAssure.code_regime =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 11) => {
|
|
||||||
cartevitale.donneesAssure.caisse_gestionnaire =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 12) => {
|
|
||||||
cartevitale.donneesAssure.centre_gestionnaire =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 13) => {
|
|
||||||
cartevitale.donneesAssure.code_gestion =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(101, 14) => {
|
|
||||||
cartevitale.donneesAssure.donnees_ruf_famille =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(102, 1) => {
|
|
||||||
cartevitale.serviceAMOFamille.code_service_amo_famille =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(102, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.serviceAMOFamille
|
|
||||||
.date_de_debut_service_amo_famille =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(102, 3) => {
|
|
||||||
cartevitale
|
|
||||||
.serviceAMOFamille
|
|
||||||
.date_de_fin_service_amo_famille =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesAccidentTravail
|
|
||||||
.organisme_gestionnaire_risque_at =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 2) => {
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAccidentTravail.code_at = byte as char;
|
|
||||||
}
|
|
||||||
(103, 3) => {
|
|
||||||
cartevitale.donneesAccidentTravail.identifiant_at =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 4) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesAccidentTravail
|
|
||||||
.organisme_gestionnaire_at1 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 5) => {
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAccidentTravail.code_at1 = byte as char;
|
|
||||||
}
|
|
||||||
(103, 6) => {
|
|
||||||
cartevitale.donneesAccidentTravail.identifiant_at1 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 7) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesAccidentTravail
|
|
||||||
.organisme_gestionnaire_at2 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(103, 8) => {
|
|
||||||
let byte = field.content[0];
|
|
||||||
cartevitale.donneesAccidentTravail.code_at2 = byte as char;
|
|
||||||
}
|
|
||||||
(103, 9) => {
|
|
||||||
cartevitale.donneesAccidentTravail.identifiant_at2 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.nom_usuel = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.nom_de_famille = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 3) => {
|
|
||||||
cartevitale.donneesBeneficiaire.last_mut().unwrap().prenom =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 4) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.adresse_ligne_1 = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 5) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.adresse_ligne_2 = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 6) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.adresse_ligne_3 = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 7) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.adresse_ligne_4 = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 8) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.adresse_ligne_5 = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 9) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.nir_certifie = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 10) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.cle_du_nir_certifie =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 11) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_certification_du_nir =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 12) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_naissance = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 13) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.rang_de_naissance = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 14) => {
|
|
||||||
cartevitale.donneesBeneficiaire.last_mut().unwrap().qualite =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 15) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.code_service_amo_beneficiaire = field.content[0] as char;
|
|
||||||
}
|
|
||||||
(104, 16) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_debut_service_amo =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 17) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_fin_service_amo =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(104, 18) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donnees_ruf_amo = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(105, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeDroitsAMO
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_debut_droits_amo =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(105, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeDroitsAMO
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_fin_droits_amo =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(106, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeCodeCouverture
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_debut_code_couverture =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(106, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeCodeCouverture
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_fin_code_couverture =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(106, 3) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeCodeCouverture
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.code_ald = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(106, 4) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.periodeCodeCouverture
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.code_situation = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(107, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.identification_mutuelle =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(107, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.garanties_effectives =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(107, 3) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.indicateur_de_traitement_mutuelle =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(107, 4) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.type_de_services_associes = field.content[0] as char;
|
|
||||||
}
|
|
||||||
(107, 5) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.services_associes_au_contrat =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(107, 6) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.code_aiguillage_sts = field.content[0] as char;
|
|
||||||
}
|
|
||||||
(108, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.periodeDroitsMutuelle
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_debut_droits_mutuelle =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(108, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesMutuelle
|
|
||||||
.periodeDroitsMutuelle
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.date_de_fin_droits_mutuelle =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.numero_complementaire_b2 =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 2) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.numero_complementaire_edi =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 3) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.numero_adherent_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 4) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.indicateur_de_traitement_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 5) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.date_de_debut_validite_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 6) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.date_de_fin_validite_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 7) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.code_routage_flux_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 8) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.identifiant_hote = String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 9) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.nom_de_domaine_amc =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(109, 10) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.code_aiguillage_sts = field.content[0] as char;
|
|
||||||
}
|
|
||||||
(109, 11) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.type_de_services_associes = field.content[0] as char;
|
|
||||||
}
|
|
||||||
(109, 12) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesComplementaire
|
|
||||||
.services_associes_au_contrat =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
(111, 1) => {
|
|
||||||
cartevitale
|
|
||||||
.donneesBeneficiaire
|
|
||||||
.last_mut()
|
|
||||||
.unwrap()
|
|
||||||
.donneesRUFBeneficiaireComplementaire
|
|
||||||
.donnees_ruf_beneficiaire_complementaire =
|
|
||||||
String::from_utf8_lossy(field.content).to_string();
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(format!(
|
|
||||||
"Unknown (group, field) pair: ({}, {})",
|
|
||||||
group.id, field.id
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(cartevitale)
|
|
||||||
}
|
|
||||||
|
|
||||||
// #[cfg(test)]
|
|
||||||
// mod test_decode_carte_ps {
|
|
||||||
// use super::*;
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// fn test_francoise_pharmacien0052419() {
|
|
||||||
// let bytes: &[u8] = &[
|
|
||||||
// 0, 1, 51, // Block 01, Content size 51
|
|
||||||
// 1, 48, // Field 01, Content size 1
|
|
||||||
// 1, 56, // Field 02, Content size 1
|
|
||||||
// 11, 57, 57, 55, 48, 48, 53, 50, 52, 49, 57, 52, // Field 03, Content size 11
|
|
||||||
// 1, 52, // Field 04, Content size 1
|
|
||||||
// 2, 50, 50, // Field 05, Content size 2
|
|
||||||
// 17, 80, 72, 65, 82, 77, 65, 67, 73, 69, 78, 48, 48, 53, 50, 52, 49,
|
|
||||||
// 57, // Field 06, Content size 17
|
|
||||||
// 9, 70, 82, 65, 78, 67, 79, 73, 83, 69, // Field 07, Content size 9
|
|
||||||
// 1, 84, // Field 08, Content size 1
|
|
||||||
// 0, 2, 83, // Block 02, Content size 83
|
|
||||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
|
||||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
|
||||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
|
||||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49,
|
|
||||||
// ];
|
|
||||||
// let blocks = decode_ssv_memory(bytes, bytes.len());
|
|
||||||
// let carte_ps = decode_carte_ps(blocks).unwrap();
|
|
||||||
|
|
||||||
// assert_eq!(carte_ps.titulaire.type_de_carte_ps, "0");
|
|
||||||
// assert_eq!(carte_ps.titulaire.type_d_identification_nationale, "8");
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.titulaire.numero_d_identification_nationale,
|
|
||||||
// "99700524194"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.titulaire.cle_du_numero_d_identification_nationale,
|
|
||||||
// "4"
|
|
||||||
// );
|
|
||||||
// assert_eq!(carte_ps.titulaire.code_civilite, "22");
|
|
||||||
// assert_eq!(carte_ps.titulaire.nom_du_ps, "PHARMACIEN0052419");
|
|
||||||
// assert_eq!(carte_ps.titulaire.prenom_du_ps, "FRANCOISE");
|
|
||||||
// assert_eq!(carte_ps.titulaire.categorie_carte, 'T');
|
|
||||||
|
|
||||||
// assert_eq!(carte_ps.situations.len(), 1);
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].numero_logique_de_la_situation_de_facturation_du_ps,
|
|
||||||
// 1
|
|
||||||
// );
|
|
||||||
// assert_eq!(carte_ps.situations[0].mode_d_exercice, "0");
|
|
||||||
// assert_eq!(carte_ps.situations[0].statut_d_exercice, "1");
|
|
||||||
// assert_eq!(carte_ps.situations[0].secteur_d_activite, "86");
|
|
||||||
// assert_eq!(carte_ps.situations[0].type_d_identification_structure, "1");
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].numero_d_identification_structure,
|
|
||||||
// "0B0221958"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].cle_du_numero_d_identification_structure,
|
|
||||||
// "8"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].raison_sociale_structure,
|
|
||||||
// "PHARMACIE DU CENTRE22195"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].numero_d_identification_de_facturation_du_ps,
|
|
||||||
// "00202419"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].cle_du_numero_d_identification_de_facturation_du_ps,
|
|
||||||
// "8"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].numero_d_identification_du_ps_remplaçant,
|
|
||||||
// ""
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].cle_du_numero_d_identification_du_ps_remplaçant,
|
|
||||||
// "0"
|
|
||||||
// );
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_conventionnel, "1");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_specialite, "50");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_zone_tarifaire, "10");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_zone_ik, "00");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_agrement_1, "0");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_agrement_2, "0");
|
|
||||||
// assert_eq!(carte_ps.situations[0].code_agrement_3, "0");
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].habilitation_à_signer_une_facture,
|
|
||||||
// "1"
|
|
||||||
// );
|
|
||||||
// assert_eq!(carte_ps.situations[0].habilitation_à_signer_un_lot, "1");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// fn test_multiple_situations() {
|
|
||||||
// let bytes: &[u8] = &[
|
|
||||||
// 0, 1, 51, // Block 01, Content size 51
|
|
||||||
// 1, 48, 1, 56, 11, 57, 57, 55, 48, 48, 53, 50, 52, 49, 57, 52, 1, 52, 2, 50, 50, 17, 80,
|
|
||||||
// 72, 65, 82, 77, 65, 67, 73, 69, 78, 48, 48, 53, 50, 52, 49, 57, 9, 70, 82, 65, 78, 67,
|
|
||||||
// 79, 73, 83, 69, 1, 84, 0, 2, 83, // Block 02, Content size 83
|
|
||||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
|
||||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
|
||||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
|
||||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 0, 3,
|
|
||||||
// 83, // Block 03, Content size 83
|
|
||||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
|
||||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
|
||||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
|
||||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 0, 4,
|
|
||||||
// 83, // Block 04, Content size 83
|
|
||||||
// 1, 1, 1, 48, 1, 49, 2, 56, 54, 1, 49, 9, 48, 66, 48, 50, 50, 49, 57, 53, 56, 1, 56, 24,
|
|
||||||
// 80, 72, 65, 82, 77, 65, 67, 73, 69, 32, 68, 85, 32, 67, 69, 78, 84, 82, 69, 50, 50, 49,
|
|
||||||
// 57, 53, 8, 48, 48, 50, 48, 50, 52, 49, 57, 1, 56, 0, 1, 48, 1, 49, 2, 53, 48, 2, 49,
|
|
||||||
// 48, 2, 48, 48, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49,
|
|
||||||
// ];
|
|
||||||
// let blocks = decode_ssv_memory(bytes, bytes.len());
|
|
||||||
// let carte_ps = decode_carte_ps(blocks).unwrap();
|
|
||||||
|
|
||||||
// assert_eq!(carte_ps.situations.len(), 3);
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[0].raison_sociale_structure,
|
|
||||||
// "PHARMACIE DU CENTRE22195"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[1].raison_sociale_structure,
|
|
||||||
// "PHARMACIE DU CENTRE22195"
|
|
||||||
// );
|
|
||||||
// assert_eq!(
|
|
||||||
// carte_ps.situations[2].raison_sociale_structure,
|
|
||||||
// "PHARMACIE DU CENTRE22195"
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// #[should_panic]
|
|
||||||
// fn test_missing_field() {
|
|
||||||
// todo!();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// #[should_panic]
|
|
||||||
// fn test_unknown_group_field_pair() {
|
|
||||||
// todo!();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// #[should_panic]
|
|
||||||
// fn test_invalid_field_format() {
|
|
||||||
// todo!();
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,5 +1,4 @@
|
|||||||
pub mod cps;
|
pub mod cps;
|
||||||
pub mod cartevitale;
|
|
||||||
pub mod libssv;
|
pub mod libssv;
|
||||||
pub mod ssv_memory;
|
pub mod ssv_memory;
|
||||||
pub mod ssvlib_demo;
|
pub mod ssvlib_demo;
|
||||||
|
@ -19,13 +19,5 @@ extern "C" {
|
|||||||
ZDonneesSortie: *mut *mut c_void,
|
ZDonneesSortie: *mut *mut c_void,
|
||||||
TTailleDonneesSortie: *mut size_t,
|
TTailleDonneesSortie: *mut size_t,
|
||||||
) -> c_ushort;
|
) -> c_ushort;
|
||||||
pub fn SSV_LireDroitsVitale(
|
|
||||||
NomRessourcePS: *const c_char,
|
|
||||||
NomRessourceLecteur: *const c_char,
|
|
||||||
CodePorteurPS: *const c_char,
|
|
||||||
DateConsultation: *const c_char,
|
|
||||||
ZDonneesSortie: *mut *mut c_void,
|
|
||||||
TTailleDonneesSortie: *mut size_t,
|
|
||||||
) -> c_ushort;
|
|
||||||
}
|
}
|
||||||
// TODO : replace void* by Rust struct : https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
// TODO : replace void* by Rust struct : https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
mod cps;
|
mod cps;
|
||||||
mod cartevitale;
|
|
||||||
mod libssv;
|
mod libssv;
|
||||||
mod ssv_memory;
|
mod ssv_memory;
|
||||||
mod ssvlib_demo;
|
mod ssvlib_demo;
|
||||||
|
@ -71,8 +71,6 @@ impl<'a> From<&'a [u8]> for Block<'a> {
|
|||||||
let mut field_id = 1;
|
let mut field_id = 1;
|
||||||
while field_offset < block_size {
|
while field_offset < block_size {
|
||||||
let mut field: Field<'a> = raw_content[field_offset..].into();
|
let mut field: Field<'a> = raw_content[field_offset..].into();
|
||||||
|
|
||||||
|
|
||||||
field.id = field_id;
|
field.id = field_id;
|
||||||
field_offset += field.size;
|
field_offset += field.size;
|
||||||
field_id += 1;
|
field_id += 1;
|
||||||
|
@ -7,10 +7,7 @@ use std::ffi::CString;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
||||||
use crate::cps::lire_carte;
|
use crate::cps::lire_carte;
|
||||||
use crate::cartevitale::LireDroitsVitale;
|
|
||||||
|
|
||||||
use crate::libssv::{SSV_InitLIB2, SSV_LireConfig};
|
use crate::libssv::{SSV_InitLIB2, SSV_LireConfig};
|
||||||
|
|
||||||
fn ssv_init_lib_2() {
|
fn ssv_init_lib_2() {
|
||||||
@ -54,15 +51,10 @@ pub fn demo() {
|
|||||||
|
|
||||||
let code_pin = "1234";
|
let code_pin = "1234";
|
||||||
let lecteur = "HID Global OMNIKEY 3x21 Smart Card Reader 0";
|
let lecteur = "HID Global OMNIKEY 3x21 Smart Card Reader 0";
|
||||||
let lecteurvitale = "HID Global OMNIKEY 3x21 Smart Card Reader 1";
|
|
||||||
let dateconsultation ="20240813";
|
|
||||||
let carte_ps = lire_carte(code_pin, lecteur).unwrap();
|
let carte_ps = lire_carte(code_pin, lecteur).unwrap();
|
||||||
println!("CartePS: {:#?}", carte_ps);
|
println!("CartePS: {:#?}", carte_ps);
|
||||||
|
|
||||||
ssv_lire_config();
|
ssv_lire_config();
|
||||||
|
|
||||||
let carte_vitale = LireDroitsVitale(lecteur, lecteurvitale, code_pin, dateconsultation).unwrap();
|
|
||||||
println!("carte_vitale: {:#?}", carte_vitale);
|
|
||||||
|
|
||||||
println!("-----------------------------------------");
|
println!("-----------------------------------------");
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,3 @@ EXPORTS
|
|||||||
SSV_InitLIB2
|
SSV_InitLIB2
|
||||||
SSV_LireCartePS
|
SSV_LireCartePS
|
||||||
SSV_LireConfig
|
SSV_LireConfig
|
||||||
SSV_LireDroitsVitale
|
|
@ -1,26 +0,0 @@
|
|||||||
@echo off
|
|
||||||
rem Set variables
|
|
||||||
set LIB_DIR=crates/sesam-vitale/lib
|
|
||||||
set DEF_DIR=crates/sesam-vitale/src/win/fsv
|
|
||||||
|
|
||||||
if "%1"=="/clean" (
|
|
||||||
goto clean
|
|
||||||
)
|
|
||||||
|
|
||||||
rem Set the environment for the x64 platform
|
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
|
|
||||||
|
|
||||||
rem Create a ssvw64.lib file from the ssvw64.def file
|
|
||||||
lib /def:ssvw64.def /out:%LIB_DIR%\ssvw64.lib /machine:x64
|
|
||||||
|
|
||||||
rem Build complete
|
|
||||||
pause
|
|
||||||
exit /b 0
|
|
||||||
|
|
||||||
:clean
|
|
||||||
del %LIB_DIR%\*.lib
|
|
||||||
del %LIB_DIR%\*.exp
|
|
||||||
|
|
||||||
rem Clean complete
|
|
||||||
pause
|
|
||||||
exit /b 0
|
|
@ -1,7 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
rem Set variables
|
rem Set variables
|
||||||
set LIB_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\lib
|
set LIB_DIR=crates/sesam-vitale/lib
|
||||||
set DEF_DIR=F:\PAPILLON\Krys4lideCopie\crates\sesam-vitale\src\win\fsv
|
set DEF_DIR=crates/sesam-vitale/src/win/fsv
|
||||||
|
|
||||||
if "%1"=="/clean" (
|
if "%1"=="/clean" (
|
||||||
goto clean
|
goto clean
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
LIBRARY "ssvw64"
|
|
||||||
EXPORTS
|
|
||||||
SSV_InitLIB2
|
|
||||||
SSV_LireCartePS
|
|
||||||
SSV_LireConfig
|
|
||||||
SSV_LireDroitsVitale
|
|
Reference in New Issue
Block a user