Add links to documentation

This commit is contained in:
QuantumEntangledAndy committed 2021-08-02 11:10:26 +07:00
1 parent 8c25de15cf
commit ae908e914b
10 files changed
+55 -53

No files matched your search

+4 -4
View File
@@ -28,14 +28,14 @@
//! which are binary data in the bc media packet format //! which are binary data in the bc media packet format
//! //!
/// `model` contains the structure of the messages such as headers and payloads /// Contains the structure of the messages such as headers and payloads
pub mod model; pub mod model;
/// `de` contains code related to the deserialisation of the bc packets /// Contains code related to the deserialisation of the bc packets
pub mod de; pub mod de;
/// `ser` contains code related to the serialisation of the bc packets /// `Contains code related to the serialisation of the bc packets
pub mod ser; pub mod ser;
/// `xml` contains the know xml payloads /// Contains the structs for the know xmls of payloads and extension
pub mod xml; pub mod xml;
mod xml_crypto; mod xml_crypto;
+19 -19
View File
@@ -42,7 +42,7 @@ pub struct Bc {
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum BcBody { pub enum BcBody {
/// Legacy is unsupported except for login where it is /// Legacy is unsupported except for login where it is used
/// to negociate the initial login and upgrade to modern /// to negociate the initial login and upgrade to modern
LegacyMsg(LegacyMsg), LegacyMsg(LegacyMsg),
/// Modern is the current reolink protocol it is mostly /// Modern is the current reolink protocol it is mostly
@@ -53,20 +53,20 @@ pub enum BcBody {
/// Modern messages have two payloads split by the `payload_offset` in the header /// Modern messages have two payloads split by the `payload_offset` in the header
/// ///
/// The first payload is extension which describes the second payload. If the /// The first payload is extension which describes the second payload. If the
/// `payload_offset` is `0` then their is no `extension` usually because it has /// `payload_offset` is `0` then their is no `extension` (usually because it has
/// already been negociated in a previous message and it is `None` /// already been negociated in a previous message) and it is `None`
/// ///
/// The second payload contains the actual data of interest and is all bytes after /// The second payload contains the actual data of interest and is all bytes after
/// the `payload_offset` up to the `body_len`. If `payload_offset` equals `body_len` /// the `payload_offset` up to the `body_len`. If `payload_offset`
/// then there is not payload and it is `None` /// equals `body_len` then there is not payload and it is `None`
/// ///
/// If payload_offset is `0` and equal to `body_len` then there is neither `extension` /// If `payload_offset` is `0` and equal to `body_len` then there is neither
/// or `payload` these are header only messages. This usually occurs to acknoledge receipt /// `extension` or `payload` these are header only messages. This usually occurs to acknoledge receipt
/// of a command. In such cases the header `response_code` should be checked. /// of a command. In such cases the header `response_code` should be checked.
/// ///
#[derive(Debug, Default, PartialEq, Eq)] #[derive(Debug, Default, PartialEq, Eq)]
pub struct ModernMsg { pub struct ModernMsg {
/// Extension describes the following payload such as which `channel_id` it is for /// Extension describes the following payload such as which channel id it is for
pub extension: Option<Extension>, pub extension: Option<Extension>,
/// Primary payload which is dependant on MsgID /// Primary payload which is dependant on MsgID
pub payload: Option<BcPayloads>, pub payload: Option<BcPayloads>,
@@ -103,25 +103,25 @@ pub(super) struct BcHeader {
/// descriptions of the Body (the application dictates these) /// descriptions of the Body (the application dictates these)
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct BcMeta { pub struct BcMeta {
/// Message ID dictaes the major content of the messahe /// Message ID dictaes the major content of the message
pub msg_id: u32, pub msg_id: u32,
/// In most cases 0 but can be other values for NVRs /// In most cases 0 but can be other values for NVRs
pub channel_id: u8, pub channel_id: u8,
/// In most cases this is unimportant but 0 means Clear Stream while 1 means Fluent stream /// In most cases this is unimportant but 0 means Clear Stream while 1 means Fluent stream
/// This is only really on `MSG_ID_VIDEO` streams when the SD `subStreams` are requested /// This is only really used during `[MSG_ID_VIDEO]` streams when the SD `subStreams` are requested
pub stream_type: u8, pub stream_type: u8,
/// On modern messages this is the response code /// On modern messages this is the response code
/// When sending a command it is set to `0` but the reply can be /// When sending a command it is set to `0`. The reply from the camera can be
/// - `200` means OK /// - `200` for OK
/// - `400` for bad request /// - `400` for bad request
/// A malformed packet will return a non `400` code /// A malformed packet will return a `400` code
pub response_code: u16, pub response_code: u16,
/// A message ID is used to match replies with requests. The camera will parrot back /// A message ID is used to match replies with requests. The camera will parrot back
/// in its reply to a message this same `msg_num` /// this number in its reply
/// ///
/// Also if there are multiple replies split over multiple messages such as in /// If there a message is too long to fit in one packet it will be split over multiple
/// streams talk or when sending a firmware update they will all have the same /// messages all with the same `msg_num` (this can happing in video streams, talk and when
/// `msg_num` /// sending a firmware update)
pub msg_num: u16, pub msg_num: u16,
/// The class is mostly an unknown quanitiy but does dictate the size of the header /// The class is mostly an unknown quanitiy but does dictate the size of the header
/// know values are /// know values are
@@ -242,13 +242,13 @@ impl BcHeader {
} }
} }
/// Constuct a `BcHeader` from a `BcMeta` /// Constuct a [`BcHeader`] from a [`BcMeta`]
/// ///
/// This requires additional data such as the `body_len` /// This requires additional data such as the `body_len`
/// ///
/// # Parameters /// # Parameters
/// ///
/// * `meta` - the `BcMeta` to convert /// * `meta` - the [`BcMeta`] to convert
/// ///
/// * `body_len` - The length of the body (extension and payload) in bytes /// * `body_len` - The length of the body (extension and payload) in bytes
/// ///
+12 -12
View File
@@ -33,7 +33,7 @@ impl Default for BcPayloads {
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
#[yaserde(rename = "body")] #[yaserde(rename = "body")]
pub struct BcXml { pub struct BcXml {
/// Encryption xml are negociated during login and contain the NONCE /// Encryption xml is received during login and contain the NONCE
#[yaserde(rename = "Encryption")] #[yaserde(rename = "Encryption")]
pub encryption: Option<Encryption>, pub encryption: Option<Encryption>,
/// LoginUser xml is used during modern login /// LoginUser xml is used during modern login
@@ -83,7 +83,7 @@ impl Extension {
/// Encryption xml /// Encryption xml
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct Encryption { pub struct Encryption {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
#[yaserde(rename = "type")] #[yaserde(rename = "type")]
@@ -96,7 +96,7 @@ pub struct Encryption {
/// LoginUser xml /// LoginUser xml
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct LoginUser { pub struct LoginUser {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
/// Username to login as /// Username to login as
@@ -112,7 +112,7 @@ pub struct LoginUser {
/// LoginNet xml /// LoginNet xml
#[derive(PartialEq, Eq, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Debug, YaDeserialize, YaSerialize)]
pub struct LoginNet { pub struct LoginNet {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
/// Type of connection usually LAN (even on wifi) /// Type of connection usually LAN (even on wifi)
@@ -179,7 +179,7 @@ pub struct Resolution {
/// This xml is used to request a stream to start /// This xml is used to request a stream to start
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct Preview { pub struct Preview {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
@@ -198,7 +198,7 @@ pub struct Preview {
/// This is used to describe the subsequent payload passed the `payload_offset` /// This is used to describe the subsequent payload passed the `payload_offset`
#[derive(PartialEq, Eq, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Debug, YaDeserialize, YaSerialize)]
pub struct Extension { pub struct Extension {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
/// If the subsequent payload is binary this will be set to 1. Otherwise it is ommited /// If the subsequent payload is binary this will be set to 1. Otherwise it is ommited
@@ -233,7 +233,7 @@ impl Default for Extension {
/// SystemGeneral xml /// SystemGeneral xml
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct SystemGeneral { pub struct SystemGeneral {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
@@ -270,7 +270,7 @@ pub struct SystemGeneral {
/// Norm xml /// Norm xml
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct Norm { pub struct Norm {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
// This is usually just `"NTSC"` // This is usually just `"NTSC"`
@@ -280,18 +280,18 @@ pub struct Norm {
/// LedState xml /// LedState xml
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)] #[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct LedState { pub struct LedState {
/// XML Version always "1.1" /// XML Version
#[yaserde(attribute)] #[yaserde(attribute)]
pub version: String, pub version: String,
/// Channel ID of camera to change its LED /// Channel ID of camera to get/set its LED state
#[yaserde(rename = "channelId")] #[yaserde(rename = "channelId")]
pub channel_id: u32, pub channel_id: u32,
/// LED Version, observed value is "2" /// LED Version, observed value is "2". Should be None when setting the LedState
#[yaserde(rename = "ledVersion")] #[yaserde(rename = "ledVersion")]
pub led_version: Option<u32>, pub led_version: Option<u32>,
/// State of the IR LEDs values are "auto", "open", "close" /// State of the IR LEDs values are "auto", "open", "close"
pub state: String, pub state: String,
/// State of the LED status light (blue on light), vallues are "open", "close" /// State of the LED status light (blue on light), values are "open", "close"
#[yaserde(rename = "lightState")] #[yaserde(rename = "lightState")]
pub light_state: String, pub light_state: String,
} }
+2 -2
View File
@@ -74,13 +74,13 @@ impl BcCamera {
/// # Parameters /// # Parameters
/// ///
/// * `host` - The address of the camera either ip address or hostname string is ok but /// * `host` - The address of the camera either ip address or hostname string is ok but
/// `SocketAddr` is fine too /// [`std::net::SocketAddr`] is fine too
/// ///
/// * `channel_id` - The channel ID this is usually zero unless using a NVR /// * `channel_id` - The channel ID this is usually zero unless using a NVR
/// ///
/// # Returns /// # Returns
/// ///
/// returns either an error of the camera /// returns either an error or the camera
/// ///
pub fn new_with_addr<T: ToSocketAddrs>(host: T, channel_id: u8) -> Result<Self> { pub fn new_with_addr<T: ToSocketAddrs>(host: T, channel_id: u8) -> Result<Self> {
let addr_iter = match host.to_socket_addrs() { let addr_iter = match host.to_socket_addrs() {
+1 -1
View File
@@ -13,7 +13,7 @@ use std::thread::JoinHandle;
use std::time::Duration; use std::time::Duration;
/// A shareable connection to a camera. Handles serialization of messages. To send/receive, call /// A shareable connection to a camera. Handles serialization of messages. To send/receive, call
/// .subscribe() with a message ID. You can use the BcSubscription to send or receive only /// .[subscribe()] with a message ID. You can use the BcSubscription to send or receive only
/// messages with that ID; each incoming message is routed to its appropriate subscriber. /// messages with that ID; each incoming message is routed to its appropriate subscriber.
/// ///
/// There can be only one subscriber per kind of message at a time. /// There can be only one subscriber per kind of message at a time.
+4 -5
View File
@@ -9,11 +9,11 @@ pub enum Error {
#[error(display = "Communication error")] #[error(display = "Communication error")]
Communication(#[error(source)] std::io::Error), Communication(#[error(source)] std::io::Error),
/// Errors raised during deserlization /// Error raised during deserlization
#[error(display = "Deserialization error")] #[error(display = "Deserialization error")]
Deserialization(#[error(source)] super::bc::de::Error), Deserialization(#[error(source)] super::bc::de::Error),
/// Errors raised during serlization /// Error raised during serlization
#[error(display = "Serialization error")] #[error(display = "Serialization error")]
Serialization(#[error(source)] super::bc::ser::Error), Serialization(#[error(source)] super::bc::ser::Error),
@@ -30,8 +30,7 @@ pub enum Error {
why: &'static str, why: &'static str,
}, },
/// Raised when a connection is dropped. This can be for many reasons /// Raised when a connection is dropped.
/// and is usually not helpful
#[error(display = "Dropped connection")] #[error(display = "Dropped connection")]
DroppedConnection(#[error(source)] std::sync::mpsc::RecvError), DroppedConnection(#[error(source)] std::sync::mpsc::RecvError),
@@ -39,7 +38,7 @@ pub enum Error {
#[error(display = "Timeout")] #[error(display = "Timeout")]
Timeout, Timeout,
/// Raised when connection is dropped because the RX_TIMEOUT is reach /// Raised when connection is dropped because the timeout is reach
#[error(display = "Dropped connection")] #[error(display = "Dropped connection")]
TimeoutDisconnected, TimeoutDisconnected,
+2 -2
View File
@@ -2,7 +2,7 @@ use super::{BcCamera, Error, Result, RX_TIMEOUT};
use crate::bc::{model::*, xml::*}; use crate::bc::{model::*, xml::*};
impl BcCamera { impl BcCamera {
/// Get the LEDState xml which contains the LED status of the camera /// Get the [LedState] xml which contains the LED status of the camera
pub fn get_ledstate(&mut self) -> Result<LedState> { pub fn get_ledstate(&mut self) -> Result<LedState> {
let connection = self let connection = self
.connection .connection
@@ -48,7 +48,7 @@ impl BcCamera {
} }
} }
/// Set the led lights using the LEDState xml /// Set the led lights using the [LedState] xml
pub fn set_ledstate(&mut self, mut led_state: LedState) -> Result<()> { pub fn set_ledstate(&mut self, mut led_state: LedState) -> Result<()> {
let connection = self let connection = self
.connection .connection
+6 -3
View File
@@ -8,6 +8,9 @@ use crate::{
}; };
/// The stream from the camera will be using one of these formats /// The stream from the camera will be using one of these formats
///
/// This is used as part of `StreamOutput` to give hints about
/// the format of the stream
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
pub enum StreamFormat { pub enum StreamFormat {
/// H264 (AVC) video format /// H264 (AVC) video format
@@ -20,10 +23,10 @@ pub enum StreamFormat {
ADPCM, ADPCM,
} }
/// Convience type for the error raised by the StreamOutput trait /// Convience type for the error raised by the [StreamOutput] trait
pub type StreamOutputError = Result<()>; pub type StreamOutputError = Result<()>;
/// The method `start_stream` requires a structure with this trait to pass the /// The method [`BcCamera::start_video()`] requires a structure with this trait to pass the
/// audio and video data back to /// audio and video data back to
pub trait StreamOutput { pub trait StreamOutput {
/// This is the callback raised when audio data is received /// This is the callback raised when audio data is received
@@ -38,7 +41,7 @@ impl BcCamera {
/// ///
/// # Parameters /// # Parameters
/// ///
/// * `data_outs` - This should be a struct that implements the `StreamOutput` trait /// * `data_outs` - This should be a struct that implements the [`StreamOutput`] trait
/// ///
/// * `stream_name` - The name of the stream either `"mainStream"` for HD or `"subStream"` for SD /// * `stream_name` - The name of the stream either `"mainStream"` for HD or `"subStream"` for SD
/// ///
+1 -1
View File
@@ -2,7 +2,7 @@ use super::{BcCamera, Error, Result, RX_TIMEOUT};
use crate::bc::{model::*, xml::*}; use crate::bc::{model::*, xml::*};
impl BcCamera { impl BcCamera {
/// Request the VersionInfo xml /// Request the [VersionInfo] xml
pub fn version(&self) -> Result<VersionInfo> { pub fn version(&self) -> Result<VersionInfo> {
let connection = self let connection = self
.connection .connection
+4 -4
View File
@@ -3,7 +3,7 @@
//! //!
//! Neolink-Core is a rust library for interacting with reolink and family cameras. //! Neolink-Core is a rust library for interacting with reolink and family cameras.
//! //!
//! Most high level camera controls are in the `neolink_core::bc_protocol` module //! Most high level camera controls are in the [`bc_protocol`] module
//! //!
//! A camera can be initialised with //! A camera can be initialised with
//! //!
@@ -19,12 +19,12 @@
//! # let camera = BcCamera::new_with_addr("camera_ip_address", channel_id); //! # let camera = BcCamera::new_with_addr("camera_ip_address", channel_id);
//! camera.login("username", "password"); //! camera.login("username", "password");
//! ``` //! ```
//! For further commands see the `BcCamera` struct. //! For further commands see the [`bc_protocol::BcCamera`] struct.
//! //!
/// `bc` module contains low level BC structures and formats /// Contains low level BC structures and formats
pub mod bc; pub mod bc;
/// `bc_protocol` contains high level interfaces for the camera /// Contains high level interfaces for the camera
pub mod bc_protocol; pub mod bc_protocol;
#[derive(Debug)] #[derive(Debug)]