[Yunq] Accept a message view on message parsing.

This commit is contained in:
Drew Galbraith 2024-01-11 20:03:34 -08:00
parent 75d84a0fa5
commit 0135d8d844
19 changed files with 94 additions and 107 deletions

View File

@ -48,7 +48,8 @@ glcr::Status DenaliClient::Read(const ReadRequest& request, ReadResponse& respon
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;
@ -87,7 +88,8 @@ glcr::Status DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;

View File

@ -15,14 +15,12 @@ struct ExtPointer {
};
} // namespace
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -71,14 +69,12 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
return next_extension;
}
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -173,16 +169,14 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
return next_extension;
}
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse memory.
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2));
return glcr::Status::Ok();
}
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse memory.
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps));

View File

@ -17,8 +17,8 @@ class ReadRequest {
ReadRequest(const ReadRequest&) = delete;
ReadRequest(ReadRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const uint64_t& device_id() const { return device_id_; }
@ -43,8 +43,8 @@ class ReadManyRequest {
ReadManyRequest(const ReadManyRequest&) = delete;
ReadManyRequest(ReadManyRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const uint64_t& device_id() const { return device_id_; }
@ -69,8 +69,8 @@ class ReadResponse {
ReadResponse(const ReadResponse&) = delete;
ReadResponse(ReadResponse&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const uint64_t& device_id() const { return device_id_; }

View File

@ -104,7 +104,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
ReadRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
@ -124,7 +125,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
ReadManyRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));

View File

@ -48,7 +48,8 @@ glcr::Status VFSClient::OpenFile(const OpenFileRequest& request, OpenFileRespons
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;
@ -87,7 +88,8 @@ glcr::Status VFSClient::GetDirectory(const GetDirectoryRequest& request, Directo
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;

View File

@ -15,14 +15,12 @@ struct ExtPointer {
};
} // namespace
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -77,16 +75,14 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
return next_extension;
}
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse memory.
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2));
return glcr::Status::Ok();
}
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse memory.
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps));
@ -156,14 +152,12 @@ uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
return next_extension;
}
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -218,14 +212,12 @@ uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
return next_extension;
}
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}

View File

@ -17,8 +17,8 @@ class OpenFileRequest {
OpenFileRequest(const OpenFileRequest&) = delete;
OpenFileRequest(OpenFileRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& path() const { return path_; }
@ -37,8 +37,8 @@ class OpenFileResponse {
OpenFileResponse(const OpenFileResponse&) = delete;
OpenFileResponse(OpenFileResponse&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& path() const { return path_; }
@ -63,8 +63,8 @@ class GetDirectoryRequest {
GetDirectoryRequest(const GetDirectoryRequest&) = delete;
GetDirectoryRequest(GetDirectoryRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& path() const { return path_; }
@ -83,8 +83,8 @@ class Directory {
Directory(const Directory&) = delete;
Directory(Directory&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& filenames() const { return filenames_; }

View File

@ -104,7 +104,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
OpenFileRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
@ -124,7 +125,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
GetDirectoryRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));

View File

@ -15,16 +15,14 @@ struct ExtPointer {
};
} // namespace
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse port_capability.
ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0));
return glcr::Status::Ok();
}
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse port_capability.
ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0, caps));

View File

@ -17,8 +17,8 @@ class KeyboardListener {
KeyboardListener(const KeyboardListener&) = delete;
KeyboardListener(KeyboardListener&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const z_cap_t& port_capability() const { return port_capability_; }

View File

@ -104,7 +104,8 @@ glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
KeyboardListener yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));

View File

@ -87,7 +87,8 @@ glcr::Status YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, E
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;
@ -126,7 +127,8 @@ glcr::Status YellowstoneClient::GetAhciInfo(AhciInfo& response) {
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;
@ -165,7 +167,8 @@ glcr::Status YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;
@ -204,7 +207,8 @@ glcr::Status YellowstoneClient::GetDenali(DenaliInfo& response) {
RET_ERR(buffer_.At<uint64_t>(8));
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
return glcr::OK;

View File

@ -17,16 +17,14 @@ struct ExtPointer {
};
} // namespace
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse endpoint_capability.
ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1));
return glcr::Status::Ok();
}
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse endpoint_capability.
ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1, caps));
@ -90,14 +88,12 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
return next_extension;
}
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -152,16 +148,14 @@ uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
return next_extension;
}
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse endpoint.
ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0));
return glcr::Status::Ok();
}
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse endpoint.
ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0, caps));
@ -201,16 +195,14 @@ uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
return next_extension;
}
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse ahci_region.
ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0));
return glcr::Status::Ok();
}
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse ahci_region.
ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0, caps));
@ -256,14 +248,12 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
return next_extension;
}
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
return glcr::Status::Ok();
}
@ -366,16 +356,14 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
return next_extension;
}
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse denali_endpoint.
ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0));
return glcr::Status::Ok();
}
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
// Parse denali_endpoint.
ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0, caps));

View File

@ -19,8 +19,8 @@ class RegisterEndpointRequest {
RegisterEndpointRequest(const RegisterEndpointRequest&) = delete;
RegisterEndpointRequest(RegisterEndpointRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& endpoint_name() const { return endpoint_name_; }
@ -42,8 +42,8 @@ class GetEndpointRequest {
GetEndpointRequest(const GetEndpointRequest&) = delete;
GetEndpointRequest(GetEndpointRequest&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const glcr::String& endpoint_name() const { return endpoint_name_; }
@ -62,8 +62,8 @@ class Endpoint {
Endpoint(const Endpoint&) = delete;
Endpoint(Endpoint&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const z_cap_t& endpoint() const { return endpoint_; }
@ -82,8 +82,8 @@ class AhciInfo {
AhciInfo(const AhciInfo&) = delete;
AhciInfo(AhciInfo&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const z_cap_t& ahci_region() const { return ahci_region_; }
@ -105,8 +105,8 @@ class FramebufferInfo {
FramebufferInfo(const FramebufferInfo&) = delete;
FramebufferInfo(FramebufferInfo&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const uint64_t& address_phys() const { return address_phys_; }
@ -158,8 +158,8 @@ class DenaliInfo {
DenaliInfo(const DenaliInfo&) = delete;
DenaliInfo(DenaliInfo&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
const z_cap_t& denali_endpoint() const { return denali_endpoint_; }

View File

@ -106,7 +106,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
RegisterEndpointRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
@ -124,7 +125,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
GetEndpointRequest yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));

View File

@ -56,7 +56,8 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}&
RET_ERR(buffer_.At<uint64_t>(8));
{% if method.response != None %}
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
yunq::MessageView resp_view(buffer_, 16);
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
{% endif %}
return glcr::OK;

View File

@ -19,8 +19,7 @@ struct ExtPointer {
} // namespace
{%- for message in messages %}
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
yunq::MessageView message(bytes, offset);
glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message) {
RETURN_ERROR(ParseFromBytesInternal(message));
{%- for field in message.fields %}
@ -37,8 +36,7 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
return glcr::Status::Ok();
}
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
yunq::MessageView message(bytes, offset);
glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
RETURN_ERROR(ParseFromBytesInternal(message));
{%- for field in message.fields %}

View File

@ -21,8 +21,8 @@ class {{message.name}} {
{{message.name}}(const {{message.name}}&) = delete;
{{message.name}}({{message.name}}&&) = delete;
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;

View File

@ -107,7 +107,8 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
{% if method.request != None %}
{{method.request}} yunq_request;
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
yunq::MessageView request_view(request, kHeaderSize);
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
{% endif %}
{% if method.response != None %}