Quellcode durchsuchen

update: Improve comments and documentation.

Alexandre Leblanc vor 5 Jahren
Ursprung
Commit
1d90a082b3
5 geänderte Dateien mit 44 neuen und 3 gelöschten Zeilen
  1. 7 0
      LICENSE.md
  2. 22 0
      README.md
  3. 7 1
      src/app_context.rs
  4. 5 2
      src/broadsign/real_time_pop_request.rs
  5. 3 0
      src/main.rs

+ 7 - 0
LICENSE.md

@@ -0,0 +1,7 @@
+Copyright 2020 Alexandre Leblanc
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 22 - 0
README.md

@@ -0,0 +1,22 @@
+# Broadsign Real-Time Pop server sample
+This is an unofficial server example. It is discouraged to use it as-is for production uses.
+It comes with no warranty.
+
+This implementation was done off hour, for hobby only.
+
+## About Real-Time Pop server implementation
+This is an implementation of version 13.2's real-time pop protocol:
+https://docs.broadsign.com/broadsign-control/13-2/real-time-pop-api.html
+
+## Using VS Code
+1. Install `rust-analyzer` and  `Rust` extensions.
+2. Recommended: Change `Rust` extension settings to use `rust-analyzer` instead of `rls` (`ctrl + ,`).
+3. Test using `cargo test`.
+3. Run using `cargo run`. Use `cargo run --release` for optimizations.
+
+## Using Insomnia
+An Insomnia file is available (`api_insomnia.json`). You may import it to help you debug or comprehend
+how to use this real-time pop server implementation.
+
+## License
+Unless otherwise specified by Broadsign International LLC, this code is MIT licensed.

+ 7 - 1
src/app_context.rs

@@ -17,6 +17,9 @@ pub struct AppContext {
     pub database: Database,
 }
 
+/* Database implementation based on SQLite.
+ * Contains some methods to simplify usage in endpoints.
+ */
 impl Database {
     pub fn from_sqlite(file_name: &'static str) -> Self {
         let manager = SqliteConnectionManager::file(file_name);
@@ -55,7 +58,7 @@ impl Database {
 
         if let Err(e) = result {
             error!("Could not create tables: {}", e);
-            panic!("Could not create tables.");
+            panic!("Could not create tables: {}", e);
         }
 
         Database {
@@ -184,6 +187,9 @@ impl Database {
     }
 }
 
+/*
+ * Test section
+ */
 #[cfg(test)]
 mod tests_database {
     use super::*;

+ 5 - 2
src/broadsign/real_time_pop_request.rs

@@ -38,8 +38,8 @@ pub struct RealTimePopEntry {
     pub extra_data: serde_json::Value,
 }
 
-/* Request sent by Broadsign Player, as defined on the website:
- * https://docs.broadsign.com/broadsign-control/13-0/real-time-pop-api.html
+/* Request sent by Broadsign Player, as defined on Broadsign's website:
+ * https://docs.broadsign.com/broadsign-control/13-2/real-time-pop-api.html
  */
 #[derive(Serialize, Deserialize, std::fmt::Debug)]
 pub struct RealTimePopRequest {
@@ -49,6 +49,9 @@ pub struct RealTimePopRequest {
     pub pops: Vec<RealTimePopEntry>,
 }
 
+/*
+ * Test section
+ */
 #[cfg(test)]
 mod protocol_serialization_tests {
     use super::*;

+ 3 - 0
src/main.rs

@@ -71,6 +71,9 @@ async fn main() -> std::io::Result<()> {
     .await
 }
 
+/*
+ * Test section
+ */
 #[cfg(test)]
 mod tests_endpoint_status {
     use super::*;