From f86a594d96950180cd6326a18e93b52387a5b564 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 20 Dec 2023 14:29:53 +0100 Subject: [PATCH] remove unnecessary set_resource_id method --- Cargo.lock | 2 +- src/resource.rs | 28 +++++----------------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83747c3..c61b8b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,7 +323,7 @@ dependencies = [ [[package]] name = "io-reactor" version = "0.2.1" -source = "git+https://github.com/rust-amplify/io-reactor?branch=resourceid#c4015910cd5ed4a4629993868b9c721ec3abb4f3" +source = "git+https://github.com/rust-amplify/io-reactor?branch=resourceid#8244a415235f9411635ddebeb5f461b70058df41" dependencies = [ "amplify", "crossbeam-channel", diff --git a/src/resource.rs b/src/resource.rs index d79d204..7e7c2d4 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -202,7 +202,10 @@ pub enum TransportState { /// Error indicating that method [`NetTransport::set_resource_id`] was called more than once. #[derive(Copy, Clone, Eq, PartialEq, Debug, Display, Error)] #[display("an attempt to re-assign resource id to {new} for net transport {current}.")] -pub struct ResIdReassigned { current: ResourceId, new: ResourceId } +pub struct ResIdReassigned { + current: ResourceId, + new: ResourceId, +} /// Net transport is an adaptor around specific [`NetSession`] (implementing /// session management, including optional handshake, encoding etc) to be used @@ -215,8 +218,6 @@ pub struct NetTransport { write_intent: bool, read_buffer: Box<[u8; HEAP_BUFFER_SIZE]>, write_buffer: VecDeque, - /// Resource id assigned by the reactor - id: Option } impl Display for NetTransport { @@ -260,7 +261,6 @@ impl NetTransport { write_intent: true, read_buffer: Box::new([0u8; READ_BUFFER_SIZE]), write_buffer: empty!(), - id: None, }) } @@ -300,28 +300,10 @@ impl NetTransport { write_intent: false, read_buffer: Box::new([0u8; READ_BUFFER_SIZE]), write_buffer: empty!(), - id: None, }) } - pub fn display(&self) -> impl Display { - match self.id { - None => self.session.display(), - Some(id) => id.to_string() - } - } - - pub fn resource_id(&self) -> Option { - self.id - } - - pub fn set_resource_id(&mut self, id: ResourceId) -> Result<(), ResIdReassigned> { - if let Some(current) = self.id { - return Err(ResIdReassigned { current, new: id }) - } - self.id = Some(id); - Ok(()) - } + pub fn display(&self) -> impl Display { self.session.display() } pub fn state(&self) -> TransportState { self.state } pub fn is_active(&self) -> bool { self.state == TransportState::Active }