#
# Generated by erpcgen 1.14.0 on Tue Apr 28 12:25:45 2026.
#
# AUTOGENERATED - DO NOT EDIT
#

import erpc
from . import common, interface

# Client for file_service
class file_serviceService(erpc.server.Service):
    def __init__(self, handler):
        super(file_serviceService, self).__init__(interface.Ifile_service.SERVICE_ID)
        self._handler = handler
        self._methods = {
                interface.Ifile_service.FILEWRITEBEGIN_ID: self._handle_fileWriteBegin,
                interface.Ifile_service.FILEWRITECHUNK_ID: self._handle_fileWriteChunk,
                interface.Ifile_service.FILEWRITEEND_ID: self._handle_fileWriteEnd,
                interface.Ifile_service.FILEWRITEABORT_ID: self._handle_fileWriteAbort,
            }

    def _handle_fileWriteBegin(self, sequence, codec):
        # Read incoming parameters.
        path = codec.read_string()
        total_size = codec.read_uint32()

        # Invoke user implementation of remote function.
        _result = self._handler.fileWriteBegin(path, total_size)

        # Prepare codec for reply message.
        codec.reset()

        # Construct reply message.
        codec.start_write_message(erpc.codec.MessageInfo(
            type=erpc.codec.MessageType.kReplyMessage,
            service=interface.Ifile_service.SERVICE_ID,
            request=interface.Ifile_service.FILEWRITEBEGIN_ID,
            sequence=sequence))
        codec.write_int32(_result)

    def _handle_fileWriteChunk(self, sequence, codec):
        # Read incoming parameters.
        data = codec.read_binary()

        # Invoke user implementation of remote function.
        _result = self._handler.fileWriteChunk(data)

        # Prepare codec for reply message.
        codec.reset()

        # Construct reply message.
        codec.start_write_message(erpc.codec.MessageInfo(
            type=erpc.codec.MessageType.kReplyMessage,
            service=interface.Ifile_service.SERVICE_ID,
            request=interface.Ifile_service.FILEWRITECHUNK_ID,
            sequence=sequence))
        codec.write_int32(_result)

    def _handle_fileWriteEnd(self, sequence, codec):
        # Read incoming parameters.

        # Invoke user implementation of remote function.
        _result = self._handler.fileWriteEnd()

        # Prepare codec for reply message.
        codec.reset()

        # Construct reply message.
        codec.start_write_message(erpc.codec.MessageInfo(
            type=erpc.codec.MessageType.kReplyMessage,
            service=interface.Ifile_service.SERVICE_ID,
            request=interface.Ifile_service.FILEWRITEEND_ID,
            sequence=sequence))
        codec.write_int32(_result)

    def _handle_fileWriteAbort(self, sequence, codec):
        # Read incoming parameters.

        # Invoke user implementation of remote function.
        _result = self._handler.fileWriteAbort()

        # Prepare codec for reply message.
        codec.reset()

        # Construct reply message.
        codec.start_write_message(erpc.codec.MessageInfo(
            type=erpc.codec.MessageType.kReplyMessage,
            service=interface.Ifile_service.SERVICE_ID,
            request=interface.Ifile_service.FILEWRITEABORT_ID,
            sequence=sequence))
        codec.write_int32(_result)


