wasefire_protocol/transfer.rs
1// Copyright 2024 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Protocol to transfer data from the host to the device.
16
17use wasefire_wire::Wire;
18
19/// Requests to transfer data.
20///
21/// The responses contain no information and just use the unit type.
22#[derive(Debug, Wire)]
23pub enum Request<'a> {
24 /// Starts a transfer.
25 Start {
26 /// Whether the transfer is a dry-run.
27 ///
28 /// In dry-run mode, all mutable operations are skipped.
29 dry_run: bool,
30 },
31
32 /// Writes a chunk of data.
33 ///
34 /// Should only be used between a `Start` and a `Finish`.
35 Write {
36 /// The next chunk of data to transfer.
37 chunk: &'a [u8],
38 },
39
40 /// Finishes a transfer.
41 Finish,
42}