Rust

SMS adapters: a dozen gateways, WhatsApp one-time passcodes, Mock for a local request catcher, and GeoSms, which routes each recipient to an adapter by calling code (calling_code).

Contents

6 submodules, and what the module defines itself.

Defined here
calling_codeCountry calling codes, and the one a phone number starts with.
ffrom_phone_numbercALGERIAcALLcANDORRAcANGOLAcARGENTINAcARMENIAcARUBAcAUSTRALIAcAUSTRIAcAZERBAIJANcBAHRAINcBANGLADESHcBELARUScBELGIUMcBELIZEcBENINcBHUTANcBOLIVIAcBOSNIA_HERZEGOVINAcBOTSWANAcBRAZILcBRUNEIcBULGARIAcBURKINA_FASOcBURUNDIcCAMBODIAcCAMEROONcCAPE_VERDE_ISLANDScCENTRAL_AFRICAN_REPUBLICcCHILEcCHINAcCOLOMBIAcCOMOROS_AND_MAYOTTEcCONGOcCOOK_ISLANDScCOSTA_RICAcCROATIAcCUBAcCYPRUScCZECH_REPUBLICcDENMARKcDJIBOUTIcECUADORcEGYPTcEL_SALVADORcEQUATORIAL_GUINEAcERITREAcESTONIAcETHIOPIAcFALKLAND_ISLANDScFAROE_ISLANDScFIJIcFINLANDcFRANCEcFRENCH_GUIANAcFRENCH_POLYNESIAcGABONcGAMBIAcGEORGIAcGERMANYcGHANAcGIBRALTARcGREECEcGREENLANDcGUADELOUPEcGUAMcGUATEMALAcGUINEAcGUINEA_BISSAUcGUYANAcHAITIcHONDURAScHONG_KONGcHUNGARYcICELANDcINDIAcINDONESIAcIRANcIRAQcIRELANDcISRAELcITALYcJAPANcJORDANcKENYAcKIRIBATIcKUWAITcKYRGYZSTANcLAOScLATVIAcLEBANONcLESOTHOcLIBERIAcLIBYAcLIECHTENSTEINcLITHUANIAcLUXEMBOURGcMACAOcMACEDONIAcMADAGASCARcMALAWIcMALAYSIAcMALDIVEScMALIcMALTAcMARSHALL_ISLANDScMARTINIQUEcMAURITANIAcMEXICOcMICRONESIAcMOLDOVAcMONACOcMONGOLIAcMOROCCOcMOZAMBIQUEcMYANMARcNAMIBIAcNAURUcNEPALcNETHERLANDScNEW_CALEDONIAcNEW_ZEALANDcNICARAGUAcNIGERcNIGERIAcNIUEcNORFOLK_ISLANDScNORTH_AMERICAcNORTH_KOREAcNORTHERN_MARIANA_ISLANDScNORWAYcOMANcPALAUcPANAMAcPAPUA_NEW_GUINEAcPARAGUAYcPERUcPHILIPPINEScPOLANDcPORTUGALcQATARcREUNIONcROMANIAcRUSSIA_KAZAKHSTAN_UZBEKISTAN_TURKMENISTAN_AND_TAJIKSTANcRWANDAcSAN_MARINOcSAO_TOME_AND_PRINCIPEcSAUDI_ARABIAcSENEGALcSERBIAcSEYCHELLEScSIERRA_LEONEcSINGAPOREcSLOVAK_REPUBLICcSLOVENIAcSOLOMON_ISLANDScSOMALIAcSOUTH_AFRICAcSOUTH_KOREAcSPAINcSRI_LANKAcST_HELENAcSUDANcSURINAMEcSWAZILANDcSWEDENcSWITZERLANDcSYRIAcTAIWANcTHAILANDcTOGOcTONGAcTUNISIAcTURKEYcTUVALUcUGANDAcUKRAINEcUNITED_ARAB_EMIRATEScUNITED_KINGDOMcURUGUAYcVANUATUcVENEZUELAcVIETNAMcWALLIS_AND_FUTUNAcYEMENcZAMBIAcZANZIBARcZIMBABWE
Rust
pub const TYPE: &str = "sms"

The kind of every SMS adapter.

sms::bird

Own page
use utopia_messaging::sms::bird::Bird;
Rust
pub struct Bird

Bird's SMS API: one recipient through the message endpoint, several through a batch Bird validates whole. The API key's region picks the host.

use utopia_messaging::sms::bird::Category;
Rust
pub enum Category

Why a message is sent; Bird requires it on every free-text send, and carriers see it.

sms::calling_code

Own page

Country calling codes, and the one a phone number starts with.

use utopia_messaging::sms::calling_code::from_phone_number;
Rust
pub fn from_phone_number(number: &str) -> Option<&'static str>

The calling code a phone number starts with, longest match first, after dropping +, spaces, parentheses and dashes, and an international prefix (00 or 011).

Rust
pub const ALGERIA: &str = "213"

+213.

Rust
pub const ALL: [(&str, &str); 187] = [ ("ALGERIA", ALGERIA), ("ANDORRA", ANDORRA), ("ANGOLA", ANGOLA), ("ARGENTINA", ARGENTINA), ("ARMENIA", ARMENIA), ("ARUBA", ARUBA), ("AUSTRALIA", AUSTRALIA), ("AUSTRIA", AUSTRIA), ("AZERBAIJAN", AZERBAIJAN), ("BAHRAIN", BAHRAIN), ("BANGLADESH", BANGLADESH), ("BELARUS", BELARUS), ("BELGIUM", BELGIUM), ("BELIZE", BELIZE), ("BENIN", BENIN), ("BHUTAN", BHUTAN), ("BOLIVIA", BOLIVIA), ("BOSNIA_HERZEGOVINA", BOSNIA_HERZEGOVINA), ("BOTSWANA", BOTSWANA), ("BRAZIL", BRAZIL), ("BRUNEI", BRUNEI), ("BULGARIA", BULGARIA), ("BURKINA_FASO", BURKINA_FASO), ("BURUNDI", BURUNDI), ("CAMBODIA", CAMBODIA), ("CAMEROON", CAMEROON), ("CAPE_VERDE_ISLANDS", CAPE_VERDE_ISLANDS), ("CENTRAL_AFRICAN_REPUBLIC", CENTRAL_AFRICAN_REPUBLIC), ("CHILE", CHILE),

Every calling code with its constant's name, in declaration order.

Rust
pub const ANDORRA: &str = "376"

+376.

Rust
pub const ANGOLA: &str = "244"

+244.

Rust
pub const ARGENTINA: &str = "54"

+54.

Rust
pub const ARMENIA: &str = "374"

+374.

Rust
pub const ARUBA: &str = "297"

+297.

Rust
pub const AUSTRALIA: &str = "61"

+61.

Rust
pub const AUSTRIA: &str = "43"

+43.

Rust
pub const AZERBAIJAN: &str = "994"

+994.

Rust
pub const BAHRAIN: &str = "973"

+973.

Rust
pub const BANGLADESH: &str = "880"

+880.

Rust
pub const BELARUS: &str = "375"

+375.

Rust
pub const BELGIUM: &str = "32"

+32.

Rust
pub const BELIZE: &str = "501"

+501.

Rust
pub const BENIN: &str = "229"

+229.

Rust
pub const BHUTAN: &str = "975"

+975.

Rust
pub const BOLIVIA: &str = "591"

+591.

Rust
pub const BOSNIA_HERZEGOVINA: &str = "387"

+387.

Rust
pub const BOTSWANA: &str = "267"

+267.

Rust
pub const BRAZIL: &str = "55"

+55.

Rust
pub const BRUNEI: &str = "673"

+673.

Rust
pub const BULGARIA: &str = "359"

+359.

Rust
pub const BURKINA_FASO: &str = "226"

+226.

Rust
pub const BURUNDI: &str = "257"

+257.

Rust
pub const CAMBODIA: &str = "855"

+855.

Rust
pub const CAMEROON: &str = "237"

+237.

Rust
pub const CAPE_VERDE_ISLANDS: &str = "238"

+238.

Rust
pub const CENTRAL_AFRICAN_REPUBLIC: &str = "236"

+236.

Rust
pub const CHILE: &str = "56"

+56.

Rust
pub const CHINA: &str = "86"

+86.

Rust
pub const COLOMBIA: &str = "57"

+57.

Rust
pub const COMOROS_AND_MAYOTTE: &str = "269"

+269.

Rust
pub const CONGO: &str = "242"

+242.

Rust
pub const COOK_ISLANDS: &str = "682"

+682.

Rust
pub const COSTA_RICA: &str = "506"

+506.

Rust
pub const CROATIA: &str = "385"

+385.

Rust
pub const CUBA: &str = "53"

+53.

Rust
pub const CYPRUS: &str = "357"

+357.

Rust
pub const CZECH_REPUBLIC: &str = "420"

+420.

Rust
pub const DENMARK: &str = "45"

+45.

Rust
pub const DJIBOUTI: &str = "253"

+253.

Rust
pub const ECUADOR: &str = "593"

+593.

Rust
pub const EGYPT: &str = "20"

+20.

Rust
pub const EL_SALVADOR: &str = "503"

+503.

Rust
pub const EQUATORIAL_GUINEA: &str = "240"

+240.

Rust
pub const ERITREA: &str = "291"

+291.

Rust
pub const ESTONIA: &str = "372"

+372.

Rust
pub const ETHIOPIA: &str = "251"

+251.

Rust
pub const FALKLAND_ISLANDS: &str = "500"

+500.

Rust
pub const FAROE_ISLANDS: &str = "298"

+298.

Rust
pub const FIJI: &str = "679"

+679.

Rust
pub const FINLAND: &str = "358"

+358.

Rust
pub const FRANCE: &str = "33"

+33.

Rust
pub const FRENCH_GUIANA: &str = "594"

+594.

Rust
pub const FRENCH_POLYNESIA: &str = "689"

+689.

Rust
pub const GABON: &str = "241"

+241.

Rust
pub const GAMBIA: &str = "220"

+220.

Rust
pub const GEORGIA: &str = "995"

+995.

Rust
pub const GERMANY: &str = "49"

+49.

Rust
pub const GHANA: &str = "233"

+233.

Rust
pub const GIBRALTAR: &str = "350"

+350.

Rust
pub const GREECE: &str = "30"

+30.

Rust
pub const GREENLAND: &str = "299"

+299.

Rust
pub const GUADELOUPE: &str = "590"

+590.

Rust
pub const GUAM: &str = "671"

+671.

Rust
pub const GUATEMALA: &str = "502"

+502.

Rust
pub const GUINEA: &str = "224"

+224.

Rust
pub const GUINEA_BISSAU: &str = "245"

+245.

Rust
pub const GUYANA: &str = "592"

+592.

Rust
pub const HAITI: &str = "509"

+509.

Rust
pub const HONDURAS: &str = "504"

+504.

Rust
pub const HONG_KONG: &str = "852"

+852.

Rust
pub const HUNGARY: &str = "36"

+36.

Rust
pub const ICELAND: &str = "354"

+354.

Rust
pub const INDIA: &str = "91"

+91.

Rust
pub const INDONESIA: &str = "62"

+62.

Rust
pub const IRAN: &str = "98"

+98.

Rust
pub const IRAQ: &str = "964"

+964.

Rust
pub const IRELAND: &str = "353"

+353.

Rust
pub const ISRAEL: &str = "972"

+972.

Rust
pub const ITALY: &str = "39"

+39.

Rust
pub const JAPAN: &str = "81"

+81.

Rust
pub const JORDAN: &str = "962"

+962.

Rust
pub const KENYA: &str = "254"

+254.

Rust
pub const KIRIBATI: &str = "686"

+686.

Rust
pub const KUWAIT: &str = "965"

+965.

Rust
pub const KYRGYZSTAN: &str = "996"

+996.

Rust
pub const LAOS: &str = "856"

+856.

Rust
pub const LATVIA: &str = "371"

+371.

Rust
pub const LEBANON: &str = "961"

+961.

Rust
pub const LESOTHO: &str = "266"

+266.

Rust
pub const LIBERIA: &str = "231"

+231.

Rust
pub const LIBYA: &str = "218"

+218.

Rust
pub const LIECHTENSTEIN: &str = "423"

+423.

Rust
pub const LITHUANIA: &str = "370"

+370.

Rust
pub const LUXEMBOURG: &str = "352"

+352.

Rust
pub const MACAO: &str = "853"

+853.

Rust
pub const MACEDONIA: &str = "389"

+389.

Rust
pub const MADAGASCAR: &str = "261"

+261.

Rust
pub const MALAWI: &str = "265"

+265.

Rust
pub const MALAYSIA: &str = "60"

+60.

Rust
pub const MALDIVES: &str = "960"

+960.

Rust
pub const MALI: &str = "223"

+223.

Rust
pub const MALTA: &str = "356"

+356.

Rust
pub const MARSHALL_ISLANDS: &str = "692"

+692.

Rust
pub const MARTINIQUE: &str = "596"

+596.

Rust
pub const MAURITANIA: &str = "222"

+222.

Rust
pub const MEXICO: &str = "52"

+52.

Rust
pub const MICRONESIA: &str = "691"

+691.

Rust
pub const MOLDOVA: &str = "373"

+373.

Rust
pub const MONACO: &str = "377"

+377.

Rust
pub const MONGOLIA: &str = "976"

+976.

Rust
pub const MOROCCO: &str = "212"

+212.

Rust
pub const MOZAMBIQUE: &str = "258"

+258.

Rust
pub const MYANMAR: &str = "95"

+95.

Rust
pub const NAMIBIA: &str = "264"

+264.

Rust
pub const NAURU: &str = "674"

+674.

Rust
pub const NEPAL: &str = "977"

+977.

Rust
pub const NETHERLANDS: &str = "31"

+31.

Rust
pub const NEW_CALEDONIA: &str = "687"

+687.

Rust
pub const NEW_ZEALAND: &str = "64"

+64.

Rust
pub const NICARAGUA: &str = "505"

+505.

Rust
pub const NIGER: &str = "227"

+227.

Rust
pub const NIGERIA: &str = "234"

+234.

Rust
pub const NIUE: &str = "683"

+683.

Rust
pub const NORFOLK_ISLANDS: &str = "672"

+672.

Rust
pub const NORTH_AMERICA: &str = "1"

+1.

Rust
pub const NORTH_KOREA: &str = "850"

+850.

Rust
pub const NORTHERN_MARIANA_ISLANDS: &str = "670"

+670.

Rust
pub const NORWAY: &str = "47"

+47.

Rust
pub const OMAN: &str = "968"

+968.

Rust
pub const PALAU: &str = "680"

+680.

Rust
pub const PANAMA: &str = "507"

+507.

Rust
pub const PAPUA_NEW_GUINEA: &str = "675"

+675.

Rust
pub const PARAGUAY: &str = "595"

+595.

Rust
pub const PERU: &str = "51"

+51.

Rust
pub const PHILIPPINES: &str = "63"

+63.

Rust
pub const POLAND: &str = "48"

+48.

Rust
pub const PORTUGAL: &str = "351"

+351.

Rust
pub const QATAR: &str = "974"

+974.

Rust
pub const REUNION: &str = "262"

+262.

Rust
pub const ROMANIA: &str = "40"

+40.

Rust
pub const RUSSIA_KAZAKHSTAN_UZBEKISTAN_TURKMENISTAN_AND_TAJIKSTAN: &str = "7"

+7.

Rust
pub const RWANDA: &str = "250"

+250.

Rust
pub const SAN_MARINO: &str = "378"

+378.

Rust
pub const SAO_TOME_AND_PRINCIPE: &str = "239"

+239.

Rust
pub const SAUDI_ARABIA: &str = "966"

+966.

Rust
pub const SENEGAL: &str = "221"

+221.

Rust
pub const SERBIA: &str = "381"

+381.

Rust
pub const SEYCHELLES: &str = "248"

+248.

Rust
pub const SIERRA_LEONE: &str = "232"

+232.

Rust
pub const SINGAPORE: &str = "65"

+65.

Rust
pub const SLOVAK_REPUBLIC: &str = "421"

+421.

Rust
pub const SLOVENIA: &str = "386"

+386.

Rust
pub const SOLOMON_ISLANDS: &str = "677"

+677.

Rust
pub const SOMALIA: &str = "252"

+252.

Rust
pub const SOUTH_AFRICA: &str = "27"

+27.

Rust
pub const SOUTH_KOREA: &str = "82"

+82.

Rust
pub const SPAIN: &str = "34"

+34.

Rust
pub const SRI_LANKA: &str = "94"

+94.

Rust
pub const ST_HELENA: &str = "290"

+290.

Rust
pub const SUDAN: &str = "249"

+249.

Rust
pub const SURINAME: &str = "597"

+597.

Rust
pub const SWAZILAND: &str = "268"

+268.

Rust
pub const SWEDEN: &str = "46"

+46.

Rust
pub const SWITZERLAND: &str = "41"

+41.

Rust
pub const SYRIA: &str = "963"

+963.

Rust
pub const TAIWAN: &str = "886"

+886.

Rust
pub const THAILAND: &str = "66"

+66.

Rust
pub const TOGO: &str = "228"

+228.

Rust
pub const TONGA: &str = "676"

+676.

Rust
pub const TUNISIA: &str = "216"

+216.

Rust
pub const TURKEY: &str = "90"

+90.

Rust
pub const TUVALU: &str = "688"

+688.

Rust
pub const UGANDA: &str = "256"

+256.

Rust
pub const UKRAINE: &str = "380"

+380.

Rust
pub const UNITED_ARAB_EMIRATES: &str = "971"

+971.

Rust
pub const UNITED_KINGDOM: &str = "44"

+44.

Rust
pub const URUGUAY: &str = "598"

+598.

Rust
pub const VANUATU: &str = "678"

+678.

Rust
pub const VENEZUELA: &str = "58"

+58.

Rust
pub const VIETNAM: &str = "84"

+84.

Rust
pub const WALLIS_AND_FUTUNA: &str = "681"

+681.

Rust
pub const YEMEN: &str = "967"

+967.

Rust
pub const ZAMBIA: &str = "260"

+260.

Rust
pub const ZANZIBAR: &str = "255"

+255.

Rust
pub const ZIMBABWE: &str = "263"

+263.

sms::fast2sms

Own page
use utopia_messaging::sms::fast2sms::Fast2Sms;
Rust
pub struct Fast2Sms

Fast2SMS's bulk API for Indian numbers: the Quick SMS route, or the DLT route with an approved sender and template.

sms::gateways

Own page

The SMS gateways with one request per send and a plain answer.

use utopia_messaging::sms::gateways::Clickatell;
Rust
pub struct Clickatell

Clickatell's SMS API.

use utopia_messaging::sms::gateways::Infobip;
Rust
pub struct Infobip

Infobip's advanced text API, on the account's own base URL.

use utopia_messaging::sms::gateways::Inforu;
Rust
pub struct Inforu

Inforu's SMS API.

use utopia_messaging::sms::gateways::Mock;
Rust
pub struct Mock

A test double posting every message to a request catcher the operator runs (any address is allowed).

use utopia_messaging::sms::gateways::Msg91;
Rust
pub struct Msg91

Msg91's flow API with a template, the content passed as the template's variables (content and otp).

use utopia_messaging::sms::gateways::Plivo;
Rust
pub struct Plivo

Plivo's message API.

use utopia_messaging::sms::gateways::Seven;
Rust
pub struct Seven

seven.io's SMS gateway.

use utopia_messaging::sms::gateways::Sinch;
Rust
pub struct Sinch

Sinch's batches API.

use utopia_messaging::sms::gateways::Telesign;
Rust
pub struct Telesign

Telesign's bulk SMS API; each recipient carries its own random external ID.

use utopia_messaging::sms::gateways::Telnyx;
Rust
pub struct Telnyx

Telnyx's messaging API (v2).

use utopia_messaging::sms::gateways::TextMagic;
Rust
pub struct TextMagic

Textmagic's messages API.

use utopia_messaging::sms::gateways::Twilio;
Rust
pub struct Twilio

Twilio's messages API, one recipient per request, from a number or a messaging service.

use utopia_messaging::sms::gateways::Vonage;
Rust
pub struct Vonage

Vonage's (Nexmo's) SMS API, one recipient per request.

use utopia_messaging::sms::gateways::Msg91Parameter;
Rust
pub enum Msg91Parameter

The Msg91 metadata the adapter forwards.

sms::geosms

Own page
use utopia_messaging::sms::geosms::GeoSms;
Rust
pub struct GeoSms

Routes each recipient to the adapter registered for its calling code, the rest to a default adapter. Consecutive recipients of one adapter go in one batch; the result is each adapter's response, by name.

Also implements Debug.

sms::whatsapp

Own page
use utopia_messaging::sms::whatsapp::App;
Rust
pub struct App

An Android app that may receive the code through one-tap or zero-tap autofill.

use utopia_messaging::sms::whatsapp::WhatsApp;
Rust
pub struct WhatsApp

One-time passcodes over WhatsApp, with a Meta Cloud API authentication template: the message content is the code itself.

use utopia_messaging::sms::whatsapp::OtpType;
Rust
pub enum OtpType

How the recipient moves the code into the app.

use utopia_messaging::sms::whatsapp::WhatsAppParameter;
Rust
pub enum WhatsAppParameter

The metadata a WhatsApp send reads.