#identifier #legal #iso #lei #entity #entities


This package contains an implementation of the ISO 17442 Legal Entity Identifier (LEI) specification

4 releases

0.1.3 Dec 25, 2022
0.1.2 Dec 23, 2022
0.1.1 Dec 7, 2022
0.1.0 Dec 7, 2022

#195 in Finance

21 downloads per month
Used in codes-iso-10383

MIT license

1.5K SLoC

Package codes-iso-17442

This package contains an implementation of the ISO 17442 Legal Entity Identifier (LEI) specification.

crates.io docs.rs

The Legal Entity Identifier (LEI) is a unique global identifier for legal entities participating in financial transactions. Also known as an LEI code or LEI number, its purpose is to help identify legal entities on a globally accessible database. Legal entities are organisations such as companies or government entities that participate in financial transactions. The identifier is used in regulatory reporting to financial regulators and all financial companies and funds are required to have an LEI.

The ISO Specification defines a format for describing identifiers and including check digits to ensure validity. In turn The Global Legal Entity Identifier Foundation (GLEIF) is the top-level maintainer of the global registry of identifiers and as such has further refined the LEI format to contain the following components:

  1. Characters 1-4: Prefix used to ensure the uniqueness among codes from LEI issuers (Local Operating Units or LOUs).
  2. Characters 5-18: Entity-specific part of the code generated and assigned by LOUs according to transparent, sound and robust allocation policies. As required by ISO 17442, it contains no embedded intelligence.
  3. Characters 19-20: Two check digits as described in the ISO 17442 standard.

GLIEF also provides daily download files for all registered identifiers, and an LEI search API.

For notes on the design of the API, see the repository README.


use codes_iso_17442::LegalEntityId;
use std::str::FromStr;

let lei = LegalEntityId::from_str("YZ83GD8L7GG84979J516").unwrap();

assert_eq!(lei.local_operating_unit(), "YZ83");
assert_eq!(lei.entity(), "GD8L7GG84979J5");
assert_eq!(lei.check_digits(), "16");


By default only the serde feature is enabled.

  • serde - Enables serialization of the LegalEntityId type.
  • url - Enables the conversion between LEI and URL (URN) forms.


Version 0.1.3

  • Catering for new build module in codes-common

Version 0.1.2

  • Moved check digit code to common package
  • Implemented Standardized and FixedLengthCode traits.

Version 0.1.0

  • Initial release




~40K SLoC