| Crates.io | legalis-eu |
| lib.rs | legalis-eu |
| version | 0.1.3 |
| created_at | 2026-01-10 14:24:53.022859+00 |
| updated_at | 2026-01-21 04:39:33.308421+00 |
| description | European Union jurisdiction support for Legalis-RS (GDPR, Consumer Rights, Competition, Treaties) |
| homepage | https://github.com/cool-japan/legalis |
| repository | https://github.com/cool-japan/legalis |
| max_upload_size | |
| id | 2034266 |
| size | 1,465,946 |
Type-safe EU law validation for Rust ๐ช๐บ
European Union jurisdiction support for Legalis-RS, providing comprehensive modeling of EU law including GDPR, Consumer Rights, Competition Law, Treaty Framework, and Intellectual Property.
๐ Quick Start Guide โข ๐ GDPR Guide โข ๐จ IP Guide โข โ FAQ โข ๐ค Contributing
use legalis_eu::gdpr::*;
// Validate GDPR data processing
let processing = DataProcessing::new()
.with_controller("My Company")
.with_purpose("Marketing emails")
.add_data_category(PersonalDataCategory::Regular("email".into()))
.with_lawful_basis(LawfulBasis::Consent {
freely_given: true,
specific: true,
informed: true,
unambiguous: true,
});
match processing.validate() {
Ok(validation) if validation.is_compliant() => {
println!("โ
GDPR compliant!");
}
Err(e) => eprintln!("โ Error: {}", e),
_ => {}
}
See the Quick Start Guide for more examples.
Add to your Cargo.toml:
[dependencies]
legalis-eu = "0.5.9"
chrono = "0.4" # Required for date/time handling
Or use cargo:
cargo add legalis-eu chrono
Current Version: v0.5.9 - Core Implementation Complete โ
Phase 1 (GDPR Foundation): โ COMPLETE
Phase 2 (GDPR Extensions): โ COMPLETE
Phase 3 (Consumer Rights): โ COMPLETE
Phase 4 (Competition Law): โ COMPLETE
Phase 5 (Treaty Framework): โ COMPLETE
Get GDPR compliance error messages in 11 EU languages:
use legalis_eu::gdpr::error::GdprError;
let error = GdprError::MissingLawfulBasis;
println!("๐ฌ๐ง {}", error.message("en")); // English
println!("๐ฉ๐ช {}", error.message("de")); // German (DSGVO)
println!("๐ซ๐ท {}", error.message("fr")); // French (RGPD)
println!("๐ช๐ธ {}", error.message("es")); // Spanish (RGPD)
println!("๐ฎ๐น {}", error.message("it")); // Italian
println!("๐ต๐ฑ {}", error.message("pl")); // Polish (RODO)
// ... and 5 more languages
Supported Languages (11 total):
Coverage:
Benefits:
See examples/gdpr_i18n_errors.rs for complete example.
Export GDPR types as JSON schemas for API documentation and validation:
use schemars::schema_for;
use legalis_eu::gdpr::types::LawfulBasis;
let schema = schema_for!(LawfulBasis);
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
Use Cases:
Enable with features: --features schema,serde
See examples/gdpr_schema_generation.rs for complete example.
Implementation of EU IP regulations:
Comprehensive implementation of the General Data Protection Regulation:
Implementation of EU consumer protection law:
Implementation of EU competition rules:
Foundational EU law structures:
use legalis_eu::gdpr::*;
let processing = DataProcessing::new()
.with_controller("Acme Corp")
.with_purpose("Marketing emails")
.add_data_category(PersonalDataCategory::Regular("email".to_string()))
.with_lawful_basis(LawfulBasis::Consent {
freely_given: true,
specific: true,
informed: true,
unambiguous: true,
});
match processing.validate() {
Ok(validation) => {
if validation.is_compliant() {
println!("โ
Processing is GDPR compliant");
}
}
Err(e) => println!("โ Error: {}", e),
}
use legalis_eu::gdpr::cross_border::*;
let transfer = CrossBorderTransfer::new()
.with_origin("EU")
.with_destination_country("US")
.with_safeguard(TransferSafeguard::StandardContractualClauses {
version: "2021".to_string(),
clauses_signed: true,
});
match transfer.validate() {
Ok(validation) => {
if validation.risk_assessment_required {
println!("โ ๏ธ Transfer Impact Assessment required (Schrems II)");
}
}
Err(e) => println!("โ Transfer not permitted: {}", e),
}
use legalis_eu::consumer_rights::*;
use chrono::Utc;
let contract = DistanceContract::new()
.with_trader("Online Shop Ltd")
.with_consumer("John Doe")
.with_contract_date(Utc::now())
.with_goods_description("Laptop computer");
match contract.calculate_withdrawal_period() {
Ok(period) => {
println!("Withdrawal deadline: {}", period.deadline);
println!("Days remaining: {}", period.days_remaining);
}
Err(e) => println!("Error: {}", e),
}
use legalis_eu::competition::*;
let agreement = Article101Agreement::new()
.with_undertaking("Company A")
.with_undertaking("Company B")
.with_agreement_type(AgreementType::Horizontal)
.add_restriction(Restriction::PriceFixing {
agreed_price: 100.0,
});
match agreement.validate() {
Ok(validation) => {
if validation.hardcore_restriction {
println!("โ Hardcore restriction - per se illegal");
}
}
Err(e) => println!("Error: {}", e),
}
Supports 11 major EU languages (extensible to all 24 official EU languages):
use legalis_eu::i18n::MultilingualText;
let text = MultilingualText::new("Data Controller")
.with_de("Verantwortlicher")
.with_fr("Responsable du traitement")
.with_es("Responsable del tratamiento")
.with_it("Titolare del trattamento")
.with_pl("Administrator danych")
.with_nl("Verwerkingsverantwoordelijke")
.with_pt("Responsรกvel pelo tratamento")
.with_sv("Personuppgiftsansvarig")
.with_cs("Sprรกvce")
.with_el("ฮฅฯฮตฯฮธฯ
ฮฝฮฟฯ ฮตฯฮตฮพฮตฯฮณฮฑฯฮฏฮฑฯ")
.with_source("CELEX:32016R0679");
assert_eq!(text.in_language("en"), "Data Controller");
assert_eq!(text.in_language("de"), "Verantwortlicher");
assert_eq!(text.in_language("pl"), "Administrator danych");
assert_eq!(text.in_language("ja"), "Data Controller"); // Fallback to EN
Proper citation handling with CELEX identifiers:
use legalis_eu::citation::EuCitation;
let gdpr = EuCitation::regulation(2016, 679).with_article(6);
assert_eq!(gdpr.format_for_language("en"), "Art. 6 GDPR");
assert_eq!(gdpr.format_for_language("de"), "Art. 6 DSGVO");
Comprehensive guides are available in the docs/ directory:
GDPR Guide - Complete GDPR implementation guide
Intellectual Property Guide - EU IP protection guide
Generate and browse the full API documentation:
cargo doc --open
Run the 23 included examples to see all features in action:
# GDPR Core
cargo run --example gdpr_consent_validation
cargo run --example gdpr_article9_special_categories
cargo run --example gdpr_dsar_handling
cargo run --example gdpr_breach_notification
# GDPR Accountability
cargo run --example gdpr_article24_accountability
cargo run --example gdpr_article25_dpbd
cargo run --example gdpr_article26_joint_controllers
cargo run --example gdpr_processor_contract
cargo run --example gdpr_ropa
# GDPR Security & Risk
cargo run --example gdpr_security_article32
cargo run --example gdpr_dpia
cargo run --example gdpr_dpia_workflow
cargo run --example gdpr_dpo
# GDPR Transfers & Fines
cargo run --example gdpr_cross_border_transfers
cargo run --example gdpr_article83_fines
# GDPR Integration
cargo run --example gdpr_complete_compliance_workflow
# Consumer Rights
cargo run --example consumer_rights_withdrawal
# Competition Law
cargo run --example competition_article101_cartels
cargo run --example competition_article102_dominance
# Intellectual Property
cargo run --example ip_eu_trademark
cargo run --example ip_copyright
cargo run --example ip_trade_secrets
cargo run --example ip_comprehensive
Run the comprehensive test suite:
cargo test -p legalis-eu # Standard tests
cargo nextest run -p legalis-eu # With nextest (recommended)
Performance benchmarks for validation operations:
cargo bench --bench gdpr_validation # GDPR validation benchmarks
cargo bench --bench ip_validation # IP validation benchmarks
Baseline Performance (typical results):
GDPR Validation:
IP Validation:
These measurements demonstrate that the crate adds minimal overhead (sub-microsecond), making it suitable for high-performance applications.
Test Coverage: 196 tests passing:
src/
โโโ lib.rs # Main module with documentation
โโโ i18n.rs # MultilingualText (11 languages, extensible to 24)
โโโ citation.rs # EUR-Lex/CELEX citation system
โโโ gdpr/ # GDPR implementation
โ โโโ types.rs # Core GDPR types
โ โโโ error.rs # GDPR-specific errors
โ โโโ article6.rs # Lawful bases (DataProcessing)
โ โโโ article9.rs # Special categories
โ โโโ article24.rs # Controller accountability
โ โโโ article25.rs # Data Protection by Design
โ โโโ article26.rs # Joint controllers
โ โโโ article30.rs # ROPA
โ โโโ processor_contract.rs # Article 28
โ โโโ dpo.rs # Articles 37-39
โ โโโ dpia.rs # Articles 35-36
โ โโโ rights.rs # Data subject rights (15-22)
โ โโโ security.rs # Security & breach (32-34)
โ โโโ cross_border.rs # Chapter V transfers
โ โโโ mod.rs
โโโ consumer_rights/ # Consumer Rights Directive
โ โโโ types.rs # Contract types
โ โโโ withdrawal.rs # Withdrawal right calculator
โ โโโ error.rs # Consumer rights errors
โ โโโ mod.rs
โโโ competition/ # Competition Law
โ โโโ article101.rs # Anti-competitive agreements
โ โโโ article102.rs # Abuse of dominance
โ โโโ types.rs # Market definition, abuse types
โ โโโ error.rs # Competition errors
โ โโโ mod.rs
โโโ treaty/ # Treaty Framework
โ โโโ types.rs # Treaty types and articles
โ โโโ four_freedoms.rs # Four freedoms
โ โโโ charter.rs # Charter of Fundamental Rights
โ โโโ case_law.rs # CJEU landmark cases
โ โโโ mod.rs
โโโ shared/
โโโ member_states.rs # EU27 + EEA registry
All EU legal instruments integrate with legalis-core:
Statute, Condition, Effect typesLegalResult::JudicialDiscretion for balancing testsLegalResult::JudicialDiscretion for balancing testslegalis-core frameworklegalis-core: Core legal framework typeslegalis-i18n: Internationalization supportchrono: Date/time handlingserde: Serialization support (optional)thiserror: Error handlinguuid: Unique identifiers for legal resultsMIT OR Apache-2.0
Contributions welcome! Areas of interest:
When contributing:
cargo clippy -- -D warnings)