[WIP] A (somewhat barebones) atproto app for creating custom sites without hosting!

upload: minor code tidy

vielle.dev ccdf5e10 d1ad6c69

verified
Changed files
+29 -59
upload
-4
upload/src/auth.rs
··· 1 - pub struct Session { 2 - pds: String, 3 - id: crate::config::Id, 4 - }
+29 -11
upload/src/main.rs
··· 1 - mod auth; 2 1 mod config; 3 - mod types; 4 2 5 3 fn main() -> Result<(), ()> { 6 - let config = config::extract(); 7 - if let Err(err) = config { 8 - match err { 9 - config::ConfigErr::TooManyDirectories => println!("Too many directories"), 10 - config::ConfigErr::NotEnoughArgs(args) => println!("Missing {}", args), 11 - config::ConfigErr::UnknownArg(arg) => println!("Unknown arg {}", arg), 12 - config::ConfigErr::NotADirectory => println!("Not a directory"), 4 + // get config items 5 + let config = match config::extract() { 6 + Ok(v) => v, 7 + Err(err) => { 8 + match err { 9 + config::ConfigErr::TooManyDirectories => println!("Too many directories"), 10 + config::ConfigErr::NotEnoughArgs(args) => println!("Missing {}", args), 11 + config::ConfigErr::UnknownArg(arg) => println!("Unknown arg {}", arg), 12 + config::ConfigErr::NotADirectory => println!("Not a directory"), 13 + } 14 + return Err(()); 13 15 } 14 - return Err(()); 15 - } 16 + }; 17 + 18 + println!( 19 + "user: {} 20 + pword: {} 21 + dir: {}", 22 + config.user, config.pword, config.dir 23 + ); 24 + 25 + // create session 26 + 27 + // get local site info 28 + 29 + // upload local site blobs 30 + 31 + // find live site records 32 + 33 + // batch delete/upload records 16 34 17 35 Ok(()) 18 36 }
-44
upload/src/types.rs
··· 1 - pub enum Did { 2 - Web(String), 3 - Plc(String), 4 - } 5 - 6 - enum DidError { 7 - UnknownMethod, 8 - MalformedDid, 9 - } 10 - 11 - impl Did { 12 - fn from(did: String) -> Result<Did, DidError> { 13 - if did.starts_with("did:plc:") { 14 - return Ok(Did::Plc(String::from(did[8..]))); 15 - } else if did.starts_with("did:web:") { 16 - return Ok(Did::Plc(String::from(did[8..]))); 17 - } else if did.starts_with("did:") { 18 - return Err(DidError::UnknownMethod); 19 - } else { 20 - return Err(DidError::MalformedDid); 21 - } 22 - } 23 - } 24 - 25 - pub struct User { 26 - handle: Option<String>, 27 - did: Did, 28 - pds: String, 29 - } 30 - 31 - enum UserFromErr { 32 - InvalidHandle, 33 - NoDidForHandle, 34 - HandleNotBidirectional, 35 - DidParseError(DidError), 36 - DidNotBidirectional, 37 - NoPds, 38 - } 39 - 40 - impl User { 41 - fn fromHandle(handle: String) -> Result<User, UserFromErr> {} 42 - 43 - fn fromDid(did: String) -> Result<User, UserFromErr> {} 44 - }