Commit da23d0f62d

da23d0f62d05e0b776b30cd77734f19b260072a4

parent: a231a27ae4

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2021-02-02 17:40 UTC

server: Put the mutable server borrows into methods

Layout: unified · split

src/server.rs +10 −3
@@ -439,6 +439,14 @@ impl MatrixServer {
439439 }
440440 }
441441
442 fn set_connection(&self, connection: Connection) {
443 *self.inner.borrow_mut().connection.borrow_mut() = Some(connection);
444 }
445
446 fn get_or_create_client(&self) -> Result<Client, ServerError> {
447 self.inner.borrow_mut().get_or_create_client()
448 }
449
442450 /// Check if the provided value is a valid URL.
443451 fn is_url_valid(value: &str) -> bool {
444452 if value.is_empty() {
@@ -605,10 +613,9 @@ impl MatrixServer {
605613 return Ok(());
606614 }
607615
608 let client = self.inner.borrow_mut().get_or_create_client()?;
616 let client = self.get_or_create_client()?;
609617 let connection = Connection::new(&self, &client);
610
611 *self.inner.borrow_mut().connection.borrow_mut() = Some(connection);
618 self.set_connection(connection);
612619
613620 self.print_network(&format!(
614621 "Connected to {}{}{}",