summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-02 21:05:17 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-08 18:43:34 +0100
commit08c400b793ecfc12b462cac91ee37c780179f5f6 (patch)
tree7dcf65d9bd50f10f0ad2c5a93a659bed73f0f757 /src
parent59cfb079b7ce09dbefb5e67791e62d746dd47ecb (diff)
Add loading of client connection
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r--src/gui/mod.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index 4574a39..97751b0 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -1,16 +1,34 @@
use anyhow::Result;
use iced::Application;
+use ipfs_api_backend_hyper::TryFromUri;
+
+use crate::client::Client;
+use crate::config::Config;
+use crate::ipfs_client::IpfsClient;
#[derive(Debug)]
struct DistroxGui;
+#[derive(Debug)]
+enum Message {
+ Loaded(Result<Client>),
+}
+
impl Application for DistroxGui {
type Executor = iced::executor::Default; // tokio
- type Message = ();
+ type Message = Message;
type Flags = ();
fn new(_flags: ()) -> (Self, iced::Command<Self::Message>) {
- (DistroxGui, iced::Command::none())
+ (
+ DistroxGui,
+ iced::Command::perform(async {
+ let ipfs = IpfsClient::from_str("http://localhost:5001")?;
+ let config = Config::default();
+ let client = Client::new(ipfs, config);
+ Ok(client)
+ }, Message::Loaded)
+ )
}
fn title(&self) -> String {