pub struct ScaleService { /* private fields */ }Expand description
ScaleService struct to manage scale operations, including capturing data
and interacting with WebSocket connections.
Implementations§
Source§impl ScaleService
impl ScaleService
Sourcepub async fn read_serial(
&self,
port: String,
write: WebSocketWrite,
uuid: String,
)
pub async fn read_serial( &self, port: String, write: WebSocketWrite, uuid: String, )
Reads data from a serial port and sends parsed values to a WebSocket.
§Arguments
port: The name of the serial port to read from.write: The WebSocket connection for sending messages.uuid: A unique identifier for the capture session.
Sourcepub async fn generate_incremental_weight(
&self,
write: WebSocketWrite,
uuid: String,
)
pub async fn generate_incremental_weight( &self, write: WebSocketWrite, uuid: String, )
Simulates incremental weight generation for testing purposes.
§Arguments
write: The WebSocket connection for sending messages.uuid: A unique identifier for the session.
Trait Implementations§
Source§impl Service for ScaleService
impl Service for ScaleService
Source§fn run<'life0, 'async_trait>(
&'life0 self,
action: Value,
write: WebSocketWrite,
) -> Pin<Box<dyn Future<Output = (i32, String)> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
action: Value,
write: WebSocketWrite,
) -> Pin<Box<dyn Future<Output = (i32, String)> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Executes an action for the scale service.
Supported actions:
- “START”: Starts data capturing from the scale. Can handle a test mode or real serial input.
- “STOP”: Stops data capturing.
§Arguments
action- A JSON value containing details of the action. Includescommand,device,port, andUUIDV4.write- AWebSocketWriteobject to communicate results back via WebSocket.
§Returns
A tuple containing:
i32- Status code (0 for success, 1 for failure).String- A descriptive message or UUID related to the action result.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Converts the service instance into a dyn Any reference.
§Returns
A reference to dyn Any for dynamic type checks.
Source§fn stop_service(&self)
fn stop_service(&self)
Stops the scale service and halts data capturing.
Ensures the following:
- Stops any ongoing capturing tasks.
- Resets internal states as needed.
Source§fn get_version(&self) -> String
fn get_version(&self) -> String
Retrieves the current version of the scale service.
§Returns
A String containing the version of the scale service.
Auto Trait Implementations§
impl Freeze for ScaleService
impl !RefUnwindSafe for ScaleService
impl Send for ScaleService
impl Sync for ScaleService
impl Unpin for ScaleService
impl !UnwindSafe for ScaleService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more