this repo has no description usp.wiro.world
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add smtp module

+45
+45
samples/smtp.usp
··· 1 + effect Throw<E> { 2 + fn throw(err: E) noreturn; 3 + } 4 + 5 + //! SMTP and DNS module 6 + 7 + pub type Domain is String; 8 + 9 + impl Domain { 10 + fn try_from(s: String) Result<Self>; 11 + fn try_from(s: String) Self \ Throw<DomainError> { 12 + // validation logic 13 + } 14 + 15 + const fn from(s: String) Self { 16 + s.try_from(s) with { 17 + // FIXME: what happens when not used at compile time? 18 + // this should work like unwrapped then 19 + Throw<DomainError>.throw |err| compile_error!("{s} is not a valid domain") 20 + } 21 + } 22 + // maybe comptime only at usage restricted by the effect required to run component 23 + } 24 + 25 + impl Domain { 26 + fn with_subdomain(self, subdomain: String) Self \ Throw { 27 + if is_dns_segment(subdomain).not() { throw; } 28 + Domain.from() 29 + } 30 + } 31 + 32 + type SmtpProvider is { 33 + domain: Domain, 34 + port: Port, 35 + security: enum { StartTls, Tls, None } // inline enum??? no? 36 + }; 37 + 38 + //! Migadu module 39 + 40 + let domain = Domain.from "smtp.migadu.com"; // should error at compile time if invalid 41 + let provider = SmtpProvider { 42 + domain: migadu_domain.with_subdomain("smtp"), 43 + port: 465, 44 + security: .Tls, 45 + }