diff options
| author | Fuwn <[email protected]> | 2021-06-06 21:00:22 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-06-06 21:00:22 -0700 |
| commit | cf14c988ce7c76136967153644fdcff75a5437da (patch) | |
| tree | 6a92f7375b37f02d30f73f2af8006941ed253664 | |
| parent | refactor(whirl_server): move orphan types out of orphan module (diff) | |
| download | whirl-cf14c988ce7c76136967153644fdcff75a5437da.tar.xz whirl-cf14c988ce7c76136967153644fdcff75a5437da.zip | |
docs(whirl_server): document more public functions
| -rw-r--r-- | crates/whirl_server/src/cmd/structure.rs | 1 | ||||
| -rw-r--r-- | crates/whirl_server/src/lib.rs | 3 | ||||
| -rw-r--r-- | crates/whirl_server/src/net/property_list.rs | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/crates/whirl_server/src/cmd/structure.rs b/crates/whirl_server/src/cmd/structure.rs index b615599..078871a 100644 --- a/crates/whirl_server/src/cmd/structure.rs +++ b/crates/whirl_server/src/cmd/structure.rs @@ -8,6 +8,7 @@ pub struct Command { pub body: Vec<u8>, } impl Command { + /// Create and return a new `Command` with default values (`0`s and empty). pub fn _new() -> Self { Self::default() } pub fn _from_byte(mut data: Vec<u8>) -> Vec<Self> { diff --git a/crates/whirl_server/src/lib.rs b/crates/whirl_server/src/lib.rs index 39cbf97..3d66122 100644 --- a/crates/whirl_server/src/lib.rs +++ b/crates/whirl_server/src/lib.rs @@ -101,6 +101,9 @@ pub trait Server { ) -> Result<(), Box<dyn Error>>; } +/// Spawn and return a vector of thread handles for each sub-server -- which +/// should be -- instantiated by the `whirl_server` crate. +/// /// # Panics /// - A panic may occur if the TCP server is unable to bind the specified port. #[must_use] diff --git a/crates/whirl_server/src/net/property_list.rs b/crates/whirl_server/src/net/property_list.rs index 4bba6c7..c91408b 100644 --- a/crates/whirl_server/src/net/property_list.rs +++ b/crates/whirl_server/src/net/property_list.rs @@ -14,6 +14,7 @@ use crate::{ pub struct PropertyList(pub Vec<crate::net::network_property::NetworkProperty>); impl PropertyList { + /// Convert a `PropertyList` to a ready-to-be sent command. pub fn as_bytes(&mut self, command_id: i32, obj_id: i32) -> Vec<u8> { let mut command = BytesMut::new(); let property_list = &mut self.0; @@ -56,12 +57,15 @@ impl PropertyList { command_as_vec } + /// Find and return a reference to a `NetworkProperty` within the associated + /// `PropertyList`. pub fn find(&self, property: i32) -> &NetworkProperty { self.0.iter().find(|i| i.prop_id == property).unwrap() } - /// Iterate over a network property in the form of bytes (Vec<u8>) and return - /// a list of human-readable properties. + /// Iterate over a property list in it's original, encoded, byte form + /// (`Vec<u8>`), and return a list of human-readable network properties + /// (`PropertyList`). pub fn from_bytes(mut data: Vec<u8>) -> Self { let mut property_list = vec![]; |