pub struct ReadRequest {
    pub offset: u64,
    pub path: Path,
}
👎Deprecated
Expand description

uavcan.file.Read.1.0

Size ranges from 6 to 118 bytes

Read file from a remote node.

There are two possible outcomes of a successful call:

  1. Data array size equals its capacity. This means that the end of the file is not reached yet.
  2. Data array size is less than its capacity, possibly zero. This means that the end of the file is reached.

Thus, if the client needs to fetch the entire file, it should repeatedly call this service while increasing the offset, until a non-full data array is returned.

If the object pointed by ‘path’ cannot be read (e.g. it is a directory or it does not exist), an appropriate error code will be returned, and the data array will be empty.

It is easy to see that this protocol is prone to race conditions because the remote file can be modified between read operations which might result in the client obtaining a damaged file. To combat this, application designers are recommended to adhere to the following convention. Let every file whose integrity is of interest have a hash or a digital signature, which is stored in an adjacent file under the same name suffixed with the appropriate extension according to the type of hash or digital signature used. For example, let there be file “image.bin”, integrity of which shall be ensured by the client upon downloading. Suppose that the file is hashed using SHA-256, so the appropriate file extension for the hash would be “.sha256”. Following this convention, the hash of “image.bin” would be stored in “image.bin.sha256”. After downloading the file, the client would read the hash (being small, the hash can be read in a single request) and check it against a locally computed value. Some servers may opt to generate such hash files automatically as necessary; for example, if such file is requested but it does not exist, the server would compute the necessary signature or hash (the type of hash/signature can be deduced from the requested file extension) and return it as if the file existed. Obviously, this would be impractical for very large files; in that case, hash/signature should be pre-computed and stored in a real file. If this approach is followed, implementers are advised to use only SHA-256 for hashing, in order to reduce the number of fielded incompatible implementations.

Fields§

§offset: u64
👎Deprecated

truncated uint40

Always aligned, size 40 bits

§path: Path
👎Deprecated

uavcan.file.Path.1.0

Always aligned, size ranges from 8 to 904 bits

Trait Implementations§

source§

impl DataType for ReadRequest

source§

const EXTENT_BYTES: Option<u32> = _

This type is delimited with an extent of 300 bytes.

source§

impl Deserialize for ReadRequest

source§

fn deserialize(cursor: &mut ReadCursor<'_>) -> Result<Self, DeserializeError>where Self: Sized,

Deserializes a value and returns it
source§

fn deserialize_from_bytes(bytes: &[u8]) -> Result<Self, DeserializeError>where Self: Sized,

A convenience function that creates a cursor around the provided bytes and calls deserialize
source§

impl Serialize for ReadRequest

source§

fn size_bits(&self) -> usize

Returns the size of the encoded form of this value, in bits Read more
source§

fn serialize(&self, cursor: &mut WriteCursor<'_>)

Serializes this value into a buffer Read more
source§

fn serialize_to_bytes(&self, bytes: &mut [u8])

A convenience function that creates a cursor around the provided bytes and calls serialize
source§

impl Request for ReadRequest

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.