diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 05ef01fa..d44f3dd7 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -173,20 +173,4 @@ ruma-identity-service-api = { version = "0.4.0", path = "../ruma-identity-servic ruma-push-gateway-api = { version = "0.4.0", path = "../ruma-push-gateway-api", optional = true } [dev-dependencies] -anyhow = "1.0.37" -isahc = "1.3.1" serde = { version = "1.0.118", features = ["derive"] } -tokio = { version = "1.0.1", features = ["macros", "rt"] } -tokio-stream = { version = "0.1.1", default-features = false } - -[[example]] -name = "hello_world" -required-features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"] - -[[example]] -name = "hello_isahc" -required-features = ["client-api-c", "client-ext-client-api", "client-isahc", "rand"] - -[[example]] -name = "message_log" -required-features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls"] diff --git a/examples/README.md b/examples/README.md index e79eb7ff..b7ec3031 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,5 +2,3 @@ These are example projects showcasing how to use the various crates in this repository. You can use these as a base for starting your own project. - -Other examples can be found in the [examples directory of the `ruma` crate](../crates/ruma/examples). diff --git a/examples/hello_isahc/Cargo.toml b/examples/hello_isahc/Cargo.toml new file mode 100644 index 00000000..f5e352cc --- /dev/null +++ b/examples/hello_isahc/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "hello_isahc" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-isahc", "rand"] } + +anyhow = "1.0.37" +isahc = "1.3.1" +tokio = { version = "1.0.1", features = ["macros", "rt"] } diff --git a/examples/hello_isahc/README.md b/examples/hello_isahc/README.md new file mode 100644 index 00000000..17060116 --- /dev/null +++ b/examples/hello_isahc/README.md @@ -0,0 +1,13 @@ +Same as the [hello_world](../hello_world) example, but using the +[isahc](https://crates.io/crates/isahc) HTTP client (a Rust wrapper around libcurl). + +# Usage + +You will need to use an existing account on a homeserver that allows login with +a password. + +In this folder, you can run it with this command: + +```shell +cargo run +``` diff --git a/crates/ruma/examples/hello_isahc.rs b/examples/hello_isahc/src/main.rs similarity index 94% rename from crates/ruma/examples/hello_isahc.rs rename to examples/hello_isahc/src/main.rs index 3777cd62..4aa20c4d 100644 --- a/crates/ruma/examples/hello_isahc.rs +++ b/examples/hello_isahc/src/main.rs @@ -1,6 +1,3 @@ -//! Same as the hello_world example, but using the isahc http client (a Rust wrapper around -//! libcurl). - use std::{convert::TryFrom, env, process::exit}; use ruma::{ diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml new file mode 100644 index 00000000..6706c0c4 --- /dev/null +++ b/examples/hello_world/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "hello_world" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"] } + +anyhow = "1.0.37" +tokio = { version = "1.0.1", features = ["macros", "rt"] } diff --git a/examples/hello_world/README.md b/examples/hello_world/README.md new file mode 100644 index 00000000..67e1e02d --- /dev/null +++ b/examples/hello_world/README.md @@ -0,0 +1,13 @@ +A simple example to demonstrate `ruma-client` functionality. Sends "Hello +World!" to the given room. + +# Usage + +You will need to use an existing account on a homeserver that allows login with +a password. + +In this folder, you can run it with this command: + +```shell +cargo run +``` diff --git a/crates/ruma/examples/hello_world.rs b/examples/hello_world/src/main.rs similarity index 98% rename from crates/ruma/examples/hello_world.rs rename to examples/hello_world/src/main.rs index 958b0279..7b606c87 100644 --- a/crates/ruma/examples/hello_world.rs +++ b/examples/hello_world/src/main.rs @@ -2,10 +2,10 @@ use std::{convert::TryFrom, env, process::exit}; use ruma::{ api::client::{alias::get_alias, membership::join_room_by_id, message::send_message_event}, + common::TransactionId, events::room::message::RoomMessageEventContent, RoomAliasId, }; -use ruma_common::TransactionId; type HttpClient = ruma::client::http_client::HyperNativeTls; diff --git a/examples/joke_bot/Cargo.toml b/examples/joke_bot/Cargo.toml index f57bbbdc..6853f851 100644 --- a/examples/joke_bot/Cargo.toml +++ b/examples/joke_bot/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client", "client-api-c", "client-ext-client-api", "client-hyper-native-tls", "events", "rand"] } +ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls", "rand"] } # For building locally: use the git dependencies below. # Browse the source at this revision here: https://github.com/ruma/ruma/tree/f161c8117c706fc52089999e1f406cf34276ec9d # ruma = { git = "https://github.com/ruma/ruma", rev = "f161c8117c706fc52089999e1f406cf34276ec9d", features = ["client-api-c", "client", "client-hyper-native-tls", "events"] } diff --git a/examples/message_log/Cargo.toml b/examples/message_log/Cargo.toml new file mode 100644 index 00000000..b82f7bbc --- /dev/null +++ b/examples/message_log/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "message_log" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ruma = { version = "0.5.0", path = "../../crates/ruma", features = ["client-api-c", "client-ext-client-api", "client-hyper-native-tls"] } + +anyhow = "1.0.37" +assign = "1.1.1" +tokio = { version = "1.0.1", features = ["macros", "rt"] } +tokio-stream = { version = "0.1.1", default-features = false } diff --git a/examples/message_log/README.md b/examples/message_log/README.md new file mode 100644 index 00000000..9c2bf8a6 --- /dev/null +++ b/examples/message_log/README.md @@ -0,0 +1,13 @@ +A simple example to demonstrate `ruma-client` functionality. Prints all the +received text messages to stdout. + +# Usage + +You will need to use an existing account on a homeserver that allows login with +a password. + +In this folder, you can run it with this command: + +```shell +cargo run +``` diff --git a/crates/ruma/examples/message_log.rs b/examples/message_log/src/main.rs similarity index 100% rename from crates/ruma/examples/message_log.rs rename to examples/message_log/src/main.rs