Update dependencies and reformat code

pull/30/head
Dominik Nakamura 1 year ago
parent 92aa54c1cd
commit 9edea8f1b7
No known key found for this signature in database

@ -18,27 +18,27 @@ features = ["events", "tls"]
[dependencies]
async-stream = { version = "0.3.3", optional = true }
base64 = "0.13.1"
base64 = "0.21.0"
bitflags = "1.3.2"
futures-util = { version = "0.3.25", features = ["sink"] }
rgb = { version = "0.8.34", default-features = false }
semver = { version = "1.0.14", features = ["serde"] }
serde = { version = "1.0.148", features = ["derive"] }
serde_json = "1.0.89"
serde_repr = "0.1.9"
serde_with = "2.1.0"
semver = { version = "1.0.16", features = ["serde"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
serde_repr = "0.1.10"
serde_with = "2.2.0"
sha2 = "0.10.6"
thiserror = "1.0.37"
thiserror = "1.0.38"
time = "0.3.17"
tokio = { version = "1.22.0", features = ["net", "rt", "sync", "time"] }
tokio = { version = "1.24.2", features = ["net", "rt", "sync", "time"] }
tokio-tungstenite = "0.18.0"
tracing = "0.1.37"
[dev-dependencies]
anyhow = "1.0.66"
anyhow = "1.0.68"
dotenvy = "0.15.6"
serde_test = "1.0.148"
tokio = { version = "1.22.0", features = ["fs", "macros", "rt-multi-thread", "time"] }
serde_test = "1.0.152"
tokio = { version = "1.24.2", features = ["fs", "macros", "rt-multi-thread", "time"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
[features]

@ -1,6 +1,7 @@
use std::env;
use anyhow::Result;
use base64::engine::{general_purpose, Engine};
use obws::{requests::sources::TakeScreenshot, Client};
use tokio::fs;
@ -25,7 +26,7 @@ async fn main() -> Result<()> {
.await?;
let pos = screenshot.find("base64,").unwrap();
let image = base64::decode(&screenshot[pos + 7..])?;
let image = general_purpose::STANDARD.decode(&screenshot[pos + 7..])?;
fs::write("screenshot.png", &image).await?;

@ -1,2 +1,7 @@
comment_width = 100
format_strings = true
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
reorder_impl_items = true
use_field_init_shorthand = true
wrap_comments = true

@ -202,6 +202,7 @@ pub(super) async fn handshake(
}
fn create_auth_response(challenge: &str, salt: &str, password: &str) -> String {
use base64::engine::{general_purpose, Engine};
use sha2::{Digest, Sha256};
let mut hasher = Sha256::new();
@ -210,13 +211,13 @@ fn create_auth_response(challenge: &str, salt: &str, password: &str) -> String {
let mut auth = String::with_capacity(Sha256::output_size() * 4 / 3 + 4);
base64::encode_config_buf(hasher.finalize_reset(), base64::STANDARD, &mut auth);
general_purpose::STANDARD.encode_string(hasher.finalize_reset(), &mut auth);
hasher.update(auth.as_bytes());
hasher.update(challenge.as_bytes());
auth.clear();
base64::encode_config_buf(hasher.finalize(), base64::STANDARD, &mut auth);
general_purpose::STANDARD.encode_string(hasher.finalize(), &mut auth);
auth
}

@ -99,8 +99,8 @@ pub enum Error {
/// event stream).
#[error("currently not connected to obs-websocket")]
Disconnected,
/// The OBS studio version of the connected instance doesn't match the required version for this
/// crate.
/// The OBS studio version of the connected instance doesn't match the required version for
/// this crate.
#[error("obs studio version {0} doesn't match required {1}")]
ObsStudioVersion(Version, Comparator),
/// The obs-websocket plugin version doesn't match the required version for this crate.

@ -157,8 +157,8 @@ pub enum CropMode<'a> {
/// List up windows with empty names in the UI drop-down selection.
show_empty_names: bool,
},
/// A combination of [`Self::ToWindow`] and [`Self::Manual`], cropping to the window first, then
/// applying manual cropping.
/// A combination of [`Self::ToWindow`] and [`Self::Manual`], cropping to the window first,
/// then applying manual cropping.
ToWindowAndManual {
/// Owner of the window. Usually the program name.
owner_name: &'a str,
@ -437,8 +437,8 @@ pub struct FfmpegSource<'a> {
pub input_format: &'a str,
/// Reconnect delay in seconds. Only used if [`Self::is_local_file`] is set to `false`.
pub reconnect_delay_sec: u8,
/// Restart playback when source becomes active. Only used if [`Self::is_local_file`] is set to
/// `true`.
/// Restart playback when source becomes active. Only used if [`Self::is_local_file`] is set
/// to `true`.
pub restart_on_activate: bool,
/// Show nothing when playback ends.
pub clear_on_media_end: bool,

@ -90,9 +90,9 @@ pub(crate) struct Identify {
pub rpc_version: u32,
#[serde(rename = "authentication")]
pub authentication: Option<String>,
/// Bit mask of event subscription items to subscribe to events and event categories at will. By
/// default, all event categories are subscribed, except for events marked as high volume. High
/// volume events must be explicitly subscribed to.
/// Bit mask of event subscription items to subscribe to events and event categories at will.
/// By default, all event categories are subscribed, except for events marked as high
/// volume. High volume events must be explicitly subscribed to.
#[serde(rename = "eventSubscriptions")]
pub event_subscriptions: Option<EventSubscription>,
}

@ -179,6 +179,8 @@ impl QtGeometry {
/// | 4 | Screen width |
/// | 16 | Main rectangle (left, top, right, bottom) 4 bytes each |
pub(crate) fn serialize(&self) -> String {
use base64::engine::{general_purpose, Engine};
/// Indicator for serialized Qt geometry data.
const MAGIC_NUMBER: u32 = 0x1D9D0CB;
/// Major version of this format.
@ -211,7 +213,7 @@ impl QtGeometry {
serialize_rect(&mut data, &self.rect);
base64::encode(data)
general_purpose::STANDARD.encode(data)
}
}
@ -265,7 +267,6 @@ impl QtWindowState {
/// │ bottom
/// │
/// Y
///
#[derive(Clone, Copy, Debug, Default)]
pub struct QtRect {
/// Left or X/horizontal position of the rectangle.

@ -20,8 +20,8 @@ pub struct Version {
/// Image formats available in `GetSourceScreenshot` and `SaveSourceScreenshot` requests.
#[serde(rename = "supportedImageFormats")]
pub supported_image_formats: Vec<String>,
/// Name of the platform. Usually `windows`, `macos`, or `ubuntu` (Linux flavor). Not guaranteed
/// to be any of those.
/// Name of the platform. Usually `windows`, `macos`, or `ubuntu` (Linux flavor). Not
/// guaranteed to be any of those.
#[serde(rename = "platform")]
pub platform: String,
/// Description of the platform, like `Windows 10 (10.0)`.

@ -24,9 +24,9 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Debug)]
pub(crate) enum ServerMessage {
/// First message sent from the server immediately on client connection. Contains authentication
/// information if authentication is required. Also contains RPC version for version
/// negotiation.
/// First message sent from the server immediately on client connection. Contains
/// authentication information if authentication is required. Also contains RPC version for
/// version negotiation.
Hello(Hello),
/// The identify request was received and validated, and the connection is now ready for normal
/// operation.
@ -65,10 +65,11 @@ impl<'de> Deserialize<'de> for ServerMessage {
Identified = 2,
/// The message sent by obs-websocket containing an event payload.
Event = 5,
/// The message sent by obs-websocket in response to a particular request from a client.
/// The message sent by obs-websocket in response to a particular request from a
/// client.
RequestResponse = 7,
/// The message sent by obs-websocket in response to a particular batch of requests from
/// a client.
/// The message sent by obs-websocket in response to a particular batch of requests
/// from a client.
RequestBatchResponse = 9,
}
@ -230,8 +231,8 @@ pub enum StatusCode {
/// The resource was not found.
///
/// **Note:** Resources are any kind of object in obs-websocket, like inputs, profiles, outputs,
/// etc.
/// **Note:** Resources are any kind of object in obs-websocket, like inputs, profiles,
/// outputs, etc.
ResourceNotFound = 600,
/// The resource already exists.
ResourceAlreadyExists = 601,

@ -221,8 +221,7 @@ mod tests {
Token::U64(u64::MAX),
Token::StructEnd,
],
"value is too large for an i64: \
out of range integral type conversion attempted",
"value is too large for an i64: out of range integral type conversion attempted",
);
}
}

Loading…
Cancel
Save