Struct grpc_vision_svc::service_impl::ComputerVisionSvc
source · pub struct ComputerVisionSvc { /* private fields */ }Expand description
The ComputerVisionSvc struct provides methods for processing images.
It holds an ImageProcessor instance and a semaphore for limiting concurrent requests.
Implementations§
source§impl ComputerVisionSvc
impl ComputerVisionSvc
sourcepub fn new(models: &Models, device: Device) -> CandleResult<Self>
pub fn new(models: &Models, device: Device) -> CandleResult<Self>
Creates a new instance of ComputerVisionSvc.
This method initializes the image processor and the semaphore for controlling the number of concurrent requests.
§Arguments
models- A reference to theModelsstruct containing the model configurations.device- The device on which the models will be loaded.
§Returns
A CandleResult containing the new ComputerVisionSvc instance or an error if
initialization fails.
Trait Implementations§
source§impl ComputerVision for ComputerVisionSvc
impl ComputerVision for ComputerVisionSvc
§type ProcessImageBatchStream = ReceiverStream<Result<ImgProcResponse, Status>>
type ProcessImageBatchStream = ReceiverStream<Result<ImgProcResponse, Status>>
The stream type for the process_image_batch method.
source§fn process_image<'life0, 'async_trait>(
&'life0 self,
request: Request<ImgProcRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ImgProcResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_image<'life0, 'async_trait>(
&'life0 self,
request: Request<ImgProcRequest>
) -> Pin<Box<dyn Future<Output = Result<Response<ImgProcResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Processes a single image and returns a description.
This method handles the processing of a single image request by validating the request, acquiring a semaphore permit to limit concurrency, and then spawning a blocking task to perform the actual image processing. The result is then sent back as a gRPC response.
§Arguments
request- A gRPCRequestcontaining theImgProcRequest.
§Returns
A [ResponseResult] containing an ImgProcResponse with the image description or a gRPC
Status on error.
§Errors
Returns a Status::invalid_argument if the request is invalid, Status::resource_exhausted
if too many concurrent requests are being processed, or Status::internal if an error occurs
during processing.
source§fn process_image_batch<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<ImgProcRequest>>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ProcessImageBatchStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_image_batch<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<ImgProcRequest>>
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ProcessImageBatchStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Processes a stream of image requests and returns a stream of responses.
This method handles the processing of a batch of image requests received as a stream.
It validates each request, acquires a semaphore permit, and spawns a blocking task for each
image processing operation. The responses are sent back as a stream of ImgProcResponse.
§Arguments
request- A gRPCRequestcontaining aStreaming<ImgProcRequest>.
§Returns
A [ResponseResult] containing a stream of ImgProcResponse or a gRPC Status on error.
§Errors
Returns a Status::resource_exhausted if too many concurrent requests are being processed,
or Status::internal if an error occurs during processing.
Auto Trait Implementations§
impl Freeze for ComputerVisionSvc
impl !RefUnwindSafe for ComputerVisionSvc
impl Send for ComputerVisionSvc
impl Sync for ComputerVisionSvc
impl Unpin for ComputerVisionSvc
impl !UnwindSafe for ComputerVisionSvc
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request