mirror of
https://github.com/aljazceru/pubky-core.git
synced 2025-12-31 12:54:35 +01:00
refactor(pubky): refactor modules
This commit is contained in:
@@ -7,10 +7,10 @@ use std::{collections::HashMap, fmt::format, time::Duration};
|
||||
use ureq::{Agent, Response};
|
||||
use url::Url;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
use pkarr::{DhtSettings, PkarrClient, Settings, Testnet};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PubkyClient {
|
||||
agent: Agent,
|
||||
@@ -40,8 +40,6 @@ impl PubkyClient {
|
||||
}
|
||||
}
|
||||
|
||||
// === Public Methods ===
|
||||
|
||||
// === Private Methods ===
|
||||
|
||||
fn request(&self, method: HttpMethod, url: &Url) -> ureq::Request {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::PubkyClient;
|
||||
use pkarr::{Keypair, PublicKey};
|
||||
|
||||
use pubky_common::{auth::AuthnSignature, session::Session};
|
||||
|
||||
use super::{Error, HttpMethod, Result};
|
||||
use pkarr::{Keypair, PublicKey};
|
||||
use super::{Error, HttpMethod, PubkyClient, Result};
|
||||
|
||||
impl PubkyClient {
|
||||
/// Signup to a homeserver and update Pkarr accordingly.
|
||||
|
||||
@@ -2,9 +2,7 @@ use bytes::Bytes;
|
||||
|
||||
use pkarr::PublicKey;
|
||||
|
||||
use crate::PubkyClient;
|
||||
|
||||
use super::Result;
|
||||
use super::{PubkyClient, Result};
|
||||
|
||||
impl PubkyClient {
|
||||
pub fn put(&self, pubky: &PublicKey, path: &str, content: &[u8]) -> Result<()> {
|
||||
|
||||
@@ -5,7 +5,7 @@ use bytes::Bytes;
|
||||
use pkarr::{Keypair, PublicKey};
|
||||
use pubky_common::session::Session;
|
||||
|
||||
use crate::{error::Result, PubkyClient};
|
||||
use crate::{client::PubkyClient, error::Result};
|
||||
|
||||
pub struct PubkyClientAsync(PubkyClient);
|
||||
|
||||
|
||||
@@ -14,18 +14,21 @@ macro_rules! if_wasm {
|
||||
)*}
|
||||
}
|
||||
|
||||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
if_not_wasm! {
|
||||
mod client;
|
||||
mod client_async;
|
||||
|
||||
pub use client::PubkyClient;
|
||||
use pkarr::{PkarrClient};
|
||||
use ureq::{Agent, Response};
|
||||
use url::Url;
|
||||
}
|
||||
|
||||
if_wasm! {
|
||||
mod wasm;
|
||||
|
||||
pub use wasm::{PubkyClient, Keypair};
|
||||
pub use wasm::keys::Keypair;
|
||||
pub use wasm::PubkyClient;
|
||||
}
|
||||
|
||||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
mod client;
|
||||
mod keys;
|
||||
mod pkarr;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
pub use client::PubkyClient;
|
||||
pub use keys::Keypair;
|
||||
pub mod auth;
|
||||
pub mod keys;
|
||||
pub mod pkarr;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct PubkyClient {
|
||||
pub(crate) pkarr: pkarr::PkarrRelayClient,
|
||||
}
|
||||
|
||||
@@ -4,15 +4,7 @@ use web_sys::RequestMode;
|
||||
|
||||
use pkarr::PkarrRelayClient;
|
||||
|
||||
use super::Keypair;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct Error {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct PubkyClient {
|
||||
pub(crate) pkarr: PkarrRelayClient,
|
||||
}
|
||||
use super::{keys::Keypair, PubkyClient};
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl PubkyClient {
|
||||
@@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*;
|
||||
|
||||
pub use pkarr::{
|
||||
dns::{rdata::SVCB, Packet},
|
||||
Keypair, PublicKey, SignedPacket,
|
||||
Keypair, PkarrRelayClient, PublicKey, SignedPacket,
|
||||
};
|
||||
|
||||
use crate::error::Result;
|
||||
|
||||
Reference in New Issue
Block a user