mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-27 21:13:47 +03:00
chore: bump rust
and fix new lints that come with it
This commit is contained in:
parent
79c4bb17ca
commit
256dae983b
21 changed files with 43 additions and 46 deletions
|
@ -21,7 +21,7 @@ version = "0.8.0-alpha"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
rust-version = "1.75.0"
|
rust-version = "1.78.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM rust:1.75.0
|
FROM rust:1.78.0
|
||||||
|
|
||||||
WORKDIR /workdir
|
WORKDIR /workdir
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
file = ./rust-toolchain.toml;
|
file = ./rust-toolchain.toml;
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
sha256 = "sha256-SXRtAuO4IqNOQq+nLbrsDFbVk+3aVA8NNpSZsKlVH/8=";
|
sha256 = "sha256-opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU=";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# If you're having trouble making the relevant changes, bug a maintainer.
|
# If you're having trouble making the relevant changes, bug a maintainer.
|
||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.75.0"
|
channel = "1.78.0"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|
|
@ -10,12 +10,12 @@ use tracing::warn;
|
||||||
///
|
///
|
||||||
/// Only returns None if there is no url specified in the appservice registration file
|
/// Only returns None if there is no url specified in the appservice registration file
|
||||||
#[tracing::instrument(skip(request))]
|
#[tracing::instrument(skip(request))]
|
||||||
pub(crate) async fn send_request<T: OutgoingRequest>(
|
pub(crate) async fn send_request<T>(
|
||||||
registration: Registration,
|
registration: Registration,
|
||||||
request: T,
|
request: T,
|
||||||
) -> Result<Option<T::IncomingResponse>>
|
) -> Result<Option<T::IncomingResponse>>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
let destination = match registration.url {
|
let destination = match registration.url {
|
||||||
Some(url) => url,
|
Some(url) => url,
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub async fn update_device_route(
|
||||||
.get_device_metadata(sender_user, &body.device_id)?
|
.get_device_metadata(sender_user, &body.device_id)?
|
||||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
||||||
|
|
||||||
device.display_name = body.display_name.clone();
|
device.display_name.clone_from(&body.display_name);
|
||||||
|
|
||||||
services()
|
services()
|
||||||
.users
|
.users
|
||||||
|
|
|
@ -213,7 +213,7 @@ pub async fn kick_user_route(
|
||||||
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
||||||
|
|
||||||
event.membership = MembershipState::Leave;
|
event.membership = MembershipState::Leave;
|
||||||
event.reason = body.reason.clone();
|
event.reason.clone_from(&body.reason);
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
services()
|
services()
|
||||||
|
@ -364,7 +364,7 @@ pub async fn unban_user_route(
|
||||||
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
||||||
|
|
||||||
event.membership = MembershipState::Leave;
|
event.membership = MembershipState::Leave;
|
||||||
event.reason = body.reason.clone();
|
event.reason.clone_from(&body.reason);
|
||||||
|
|
||||||
let mutex_state = Arc::clone(
|
let mutex_state = Arc::clone(
|
||||||
services()
|
services()
|
||||||
|
|
|
@ -286,7 +286,7 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut http_request = http::Request::builder().uri(parts.uri).method(parts.method);
|
let mut http_request = Request::builder().uri(parts.uri).method(parts.method);
|
||||||
*http_request.headers_mut().unwrap() = parts.headers;
|
*http_request.headers_mut().unwrap() = parts.headers;
|
||||||
|
|
||||||
if let Some(CanonicalJsonValue::Object(json_body)) = &mut json_body {
|
if let Some(CanonicalJsonValue::Object(json_body)) = &mut json_body {
|
||||||
|
|
|
@ -116,12 +116,12 @@ impl FedDest {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(request))]
|
#[tracing::instrument(skip(request))]
|
||||||
pub(crate) async fn send_request<T: OutgoingRequest>(
|
pub(crate) async fn send_request<T>(
|
||||||
destination: &ServerName,
|
destination: &ServerName,
|
||||||
request: T,
|
request: T,
|
||||||
) -> Result<T::IncomingResponse>
|
) -> Result<T::IncomingResponse>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
if !services().globals.allow_federation() {
|
if !services().globals.allow_federation() {
|
||||||
return Err(Error::bad_config("Federation is disabled."));
|
return Err(Error::bad_config("Federation is disabled."));
|
||||||
|
|
|
@ -38,7 +38,6 @@ pub trait KeyValueDatabaseEngine: Send + Sync {
|
||||||
fn memory_usage(&self) -> Result<String> {
|
fn memory_usage(&self) -> Result<String> {
|
||||||
Ok("Current database engine does not support memory usage reporting.".to_owned())
|
Ok("Current database engine does not support memory usage reporting.".to_owned())
|
||||||
}
|
}
|
||||||
fn clear_caches(&self) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait KvTree: Send + Sync {
|
pub trait KvTree: Send + Sync {
|
||||||
|
|
|
@ -126,8 +126,6 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||||
self.cache.get_pinned_usage() as f64 / 1024.0 / 1024.0,
|
self.cache.get_pinned_usage() as f64 / 1024.0 / 1024.0,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_caches(&self) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RocksDbEngineTree<'_> {
|
impl RocksDbEngineTree<'_> {
|
||||||
|
|
|
@ -13,8 +13,8 @@ use thread_local::ThreadLocal;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static READ_CONNECTION: RefCell<Option<&'static Connection>> = RefCell::new(None);
|
static READ_CONNECTION: RefCell<Option<&'static Connection>> = const { RefCell::new(None) };
|
||||||
static READ_CONNECTION_ITERATOR: RefCell<Option<&'static Connection>> = RefCell::new(None);
|
static READ_CONNECTION_ITERATOR: RefCell<Option<&'static Connection>> = const { RefCell::new(None) };
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreparedStatementIterator<'a> {
|
struct PreparedStatementIterator<'a> {
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Watchers {
|
||||||
let mut rx = match self.watchers.write().unwrap().entry(prefix.to_vec()) {
|
let mut rx = match self.watchers.write().unwrap().entry(prefix.to_vec()) {
|
||||||
hash_map::Entry::Occupied(o) => o.get().1.clone(),
|
hash_map::Entry::Occupied(o) => o.get().1.clone(),
|
||||||
hash_map::Entry::Vacant(v) => {
|
hash_map::Entry::Vacant(v) => {
|
||||||
let (tx, rx) = tokio::sync::watch::channel(());
|
let (tx, rx) = watch::channel(());
|
||||||
v.insert((tx, rx.clone()));
|
v.insert((tx, rx.clone()));
|
||||||
rx
|
rx
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ impl KeyValueDatabase {
|
||||||
Self::check_db_setup(&config)?;
|
Self::check_db_setup(&config)?;
|
||||||
|
|
||||||
if !Path::new(&config.database_path).exists() {
|
if !Path::new(&config.database_path).exists() {
|
||||||
std::fs::create_dir_all(&config.database_path)
|
fs::create_dir_all(&config.database_path)
|
||||||
.map_err(|_| Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself."))?;
|
.map_err(|_| Error::BadConfig("Database folder doesn't exists and couldn't be created (e.g. due to missing permissions). Please create the database folder yourself."))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,7 +846,7 @@ impl KeyValueDatabase {
|
||||||
let rule = rules_list.content.get(content_rule_transformation[0]);
|
let rule = rules_list.content.get(content_rule_transformation[0]);
|
||||||
if rule.is_some() {
|
if rule.is_some() {
|
||||||
let mut rule = rule.unwrap().clone();
|
let mut rule = rule.unwrap().clone();
|
||||||
rule.rule_id = content_rule_transformation[1].to_owned();
|
content_rule_transformation[1].clone_into(&mut rule.rule_id);
|
||||||
rules_list
|
rules_list
|
||||||
.content
|
.content
|
||||||
.shift_remove(content_rule_transformation[0]);
|
.shift_remove(content_rule_transformation[0]);
|
||||||
|
@ -871,7 +871,7 @@ impl KeyValueDatabase {
|
||||||
let rule = rules_list.underride.get(transformation[0]);
|
let rule = rules_list.underride.get(transformation[0]);
|
||||||
if let Some(rule) = rule {
|
if let Some(rule) = rule {
|
||||||
let mut rule = rule.clone();
|
let mut rule = rule.clone();
|
||||||
rule.rule_id = transformation[1].to_owned();
|
transformation[1].clone_into(&mut rule.rule_id);
|
||||||
rules_list.underride.shift_remove(transformation[0]);
|
rules_list.underride.shift_remove(transformation[0]);
|
||||||
rules_list.underride.insert(rule);
|
rules_list.underride.insert(rule);
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ impl KeyValueDatabase {
|
||||||
let mut account_data =
|
let mut account_data =
|
||||||
serde_json::from_str::<PushRulesEvent>(raw_rules_list.get()).unwrap();
|
serde_json::from_str::<PushRulesEvent>(raw_rules_list.get()).unwrap();
|
||||||
|
|
||||||
let user_default_rules = ruma::push::Ruleset::server_default(&user);
|
let user_default_rules = Ruleset::server_default(&user);
|
||||||
account_data
|
account_data
|
||||||
.content
|
.content
|
||||||
.global
|
.global
|
||||||
|
|
|
@ -217,7 +217,7 @@ async fn run_server() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn spawn_task<B: Send + 'static>(
|
async fn spawn_task<B: Send + 'static>(
|
||||||
req: axum::http::Request<B>,
|
req: http::Request<B>,
|
||||||
next: axum::middleware::Next<B>,
|
next: axum::middleware::Next<B>,
|
||||||
) -> std::result::Result<axum::response::Response, StatusCode> {
|
) -> std::result::Result<axum::response::Response, StatusCode> {
|
||||||
if services().globals.shutdown.load(atomic::Ordering::Relaxed) {
|
if services().globals.shutdown.load(atomic::Ordering::Relaxed) {
|
||||||
|
@ -229,13 +229,13 @@ async fn spawn_task<B: Send + 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn unrecognized_method<B: Send>(
|
async fn unrecognized_method<B: Send>(
|
||||||
req: axum::http::Request<B>,
|
req: http::Request<B>,
|
||||||
next: axum::middleware::Next<B>,
|
next: axum::middleware::Next<B>,
|
||||||
) -> std::result::Result<axum::response::Response, StatusCode> {
|
) -> std::result::Result<axum::response::Response, StatusCode> {
|
||||||
let method = req.method().clone();
|
let method = req.method().clone();
|
||||||
let uri = req.uri().clone();
|
let uri = req.uri().clone();
|
||||||
let inner = next.run(req).await;
|
let inner = next.run(req).await;
|
||||||
if inner.status() == axum::http::StatusCode::METHOD_NOT_ALLOWED {
|
if inner.status() == StatusCode::METHOD_NOT_ALLOWED {
|
||||||
warn!("Method not allowed: {method} {uri}");
|
warn!("Method not allowed: {method} {uri}");
|
||||||
return Ok(RumaResponse(UiaaResponse::MatrixError(RumaError {
|
return Ok(RumaResponse(UiaaResponse::MatrixError(RumaError {
|
||||||
body: ErrorBody::Standard {
|
body: ErrorBody::Standard {
|
||||||
|
|
|
@ -80,12 +80,12 @@ pub struct Service {
|
||||||
/// Handles "rotation" of long-polling requests. "Rotation" in this context is similar to "rotation" of log files and the like.
|
/// Handles "rotation" of long-polling requests. "Rotation" in this context is similar to "rotation" of log files and the like.
|
||||||
///
|
///
|
||||||
/// This is utilized to have sync workers return early and release read locks on the database.
|
/// This is utilized to have sync workers return early and release read locks on the database.
|
||||||
pub struct RotationHandler(broadcast::Sender<()>, broadcast::Receiver<()>);
|
pub struct RotationHandler(broadcast::Sender<()>);
|
||||||
|
|
||||||
impl RotationHandler {
|
impl RotationHandler {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let (s, r) = broadcast::channel(1);
|
let s = broadcast::channel(1).0;
|
||||||
Self(s, r)
|
Self(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn watch(&self) -> impl Future<Output = ()> {
|
pub fn watch(&self) -> impl Future<Output = ()> {
|
||||||
|
|
|
@ -44,13 +44,13 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, destination, request))]
|
#[tracing::instrument(skip(self, destination, request))]
|
||||||
pub async fn send_request<T: OutgoingRequest>(
|
pub async fn send_request<T>(
|
||||||
&self,
|
&self,
|
||||||
destination: &str,
|
destination: &str,
|
||||||
request: T,
|
request: T,
|
||||||
) -> Result<T::IncomingResponse>
|
) -> Result<T::IncomingResponse>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
let destination = destination.replace("/_matrix/push/v1/notify", "");
|
let destination = destination.replace("/_matrix/push/v1/notify", "");
|
||||||
|
|
||||||
|
@ -231,11 +231,11 @@ impl Service {
|
||||||
|
|
||||||
let mut device = Device::new(pusher.ids.app_id.clone(), pusher.ids.pushkey.clone());
|
let mut device = Device::new(pusher.ids.app_id.clone(), pusher.ids.pushkey.clone());
|
||||||
device.data.default_payload = http.default_payload.clone();
|
device.data.default_payload = http.default_payload.clone();
|
||||||
device.data.format = http.format.clone();
|
device.data.format.clone_from(&http.format);
|
||||||
|
|
||||||
// Tweaks are only added if the format is NOT event_id_only
|
// Tweaks are only added if the format is NOT event_id_only
|
||||||
if !event_id_only {
|
if !event_id_only {
|
||||||
device.tweaks = tweaks.clone();
|
device.tweaks.clone_from(&tweaks);
|
||||||
}
|
}
|
||||||
|
|
||||||
let d = vec![device];
|
let d = vec![device];
|
||||||
|
|
|
@ -482,7 +482,7 @@ impl Service {
|
||||||
match join_rule {
|
match join_rule {
|
||||||
JoinRule::Restricted(r) => {
|
JoinRule::Restricted(r) => {
|
||||||
for rule in &r.allow {
|
for rule in &r.allow {
|
||||||
if let join_rules::AllowRule::RoomMembership(rm) = rule {
|
if let AllowRule::RoomMembership(rm) = rule {
|
||||||
if let Ok(true) = services()
|
if let Ok(true) = services()
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
|
|
|
@ -675,13 +675,13 @@ impl Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, destination, request))]
|
#[tracing::instrument(skip(self, destination, request))]
|
||||||
pub async fn send_federation_request<T: OutgoingRequest>(
|
pub async fn send_federation_request<T>(
|
||||||
&self,
|
&self,
|
||||||
destination: &ServerName,
|
destination: &ServerName,
|
||||||
request: T,
|
request: T,
|
||||||
) -> Result<T::IncomingResponse>
|
) -> Result<T::IncomingResponse>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
debug!("Waiting for permit");
|
debug!("Waiting for permit");
|
||||||
let permit = self.maximum_requests.acquire().await;
|
let permit = self.maximum_requests.acquire().await;
|
||||||
|
@ -704,13 +704,13 @@ impl Service {
|
||||||
///
|
///
|
||||||
/// Only returns None if there is no url specified in the appservice registration file
|
/// Only returns None if there is no url specified in the appservice registration file
|
||||||
#[tracing::instrument(skip(self, registration, request))]
|
#[tracing::instrument(skip(self, registration, request))]
|
||||||
pub async fn send_appservice_request<T: OutgoingRequest>(
|
pub async fn send_appservice_request<T>(
|
||||||
&self,
|
&self,
|
||||||
registration: Registration,
|
registration: Registration,
|
||||||
request: T,
|
request: T,
|
||||||
) -> Result<Option<T::IncomingResponse>>
|
) -> Result<Option<T::IncomingResponse>>
|
||||||
where
|
where
|
||||||
T: Debug,
|
T: OutgoingRequest + Debug,
|
||||||
{
|
{
|
||||||
let permit = self.maximum_requests.acquire().await;
|
let permit = self.maximum_requests.acquire().await;
|
||||||
let response = appservice_server::send_request(registration, request).await;
|
let response = appservice_server::send_request(registration, request).await;
|
||||||
|
|
|
@ -86,11 +86,12 @@ impl Service {
|
||||||
for (list_id, list) in &mut request.lists {
|
for (list_id, list) in &mut request.lists {
|
||||||
if let Some(cached_list) = cached.lists.get(list_id) {
|
if let Some(cached_list) = cached.lists.get(list_id) {
|
||||||
if list.sort.is_empty() {
|
if list.sort.is_empty() {
|
||||||
list.sort = cached_list.sort.clone();
|
list.sort.clone_from(&cached_list.sort);
|
||||||
};
|
};
|
||||||
if list.room_details.required_state.is_empty() {
|
if list.room_details.required_state.is_empty() {
|
||||||
list.room_details.required_state =
|
list.room_details
|
||||||
cached_list.room_details.required_state.clone();
|
.required_state
|
||||||
|
.clone_from(&cached_list.room_details.required_state);
|
||||||
};
|
};
|
||||||
list.room_details.timeline_limit = list
|
list.room_details.timeline_limit = list
|
||||||
.room_details
|
.room_details
|
||||||
|
@ -132,7 +133,8 @@ impl Service {
|
||||||
(_, _) => {}
|
(_, _) => {}
|
||||||
}
|
}
|
||||||
if list.bump_event_types.is_empty() {
|
if list.bump_event_types.is_empty() {
|
||||||
list.bump_event_types = cached_list.bump_event_types.clone();
|
list.bump_event_types
|
||||||
|
.clone_from(&cached_list.bump_event_types);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
cached.lists.insert(list_id.clone(), list.clone());
|
cached.lists.insert(list_id.clone(), list.clone());
|
||||||
|
|
|
@ -122,16 +122,14 @@ pub fn deserialize_from_str<
|
||||||
'de,
|
'de,
|
||||||
D: serde::de::Deserializer<'de>,
|
D: serde::de::Deserializer<'de>,
|
||||||
T: FromStr<Err = E>,
|
T: FromStr<Err = E>,
|
||||||
E: std::fmt::Display,
|
E: fmt::Display,
|
||||||
>(
|
>(
|
||||||
deserializer: D,
|
deserializer: D,
|
||||||
) -> Result<T, D::Error> {
|
) -> Result<T, D::Error> {
|
||||||
struct Visitor<T: FromStr<Err = E>, E>(std::marker::PhantomData<T>);
|
struct Visitor<T: FromStr<Err = E>, E>(std::marker::PhantomData<T>);
|
||||||
impl<'de, T: FromStr<Err = Err>, Err: std::fmt::Display> serde::de::Visitor<'de>
|
impl<'de, T: FromStr<Err = Err>, Err: fmt::Display> serde::de::Visitor<'de> for Visitor<T, Err> {
|
||||||
for Visitor<T, Err>
|
|
||||||
{
|
|
||||||
type Value = T;
|
type Value = T;
|
||||||
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(formatter, "a parsable string")
|
write!(formatter, "a parsable string")
|
||||||
}
|
}
|
||||||
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
|
||||||
|
|
Loading…
Reference in a new issue