Struct edjx::stream::ReadStream

source ·
pub struct ReadStream { /* private fields */ }
Expand description

ReadStream is used to receive streamed data.

Implementations§

Reads a chunk of binary data from the stream.

Examples found in repository?
src/stream.rs (line 161)
158
159
160
161
162
163
164
165
166
167
168
169
170
171
    pub fn read_all(&mut self) -> Result<Vec<u8>, StreamError> {
        let mut all_bytes = Vec::new();

        while let Some(bytes_res) = self.read_chunk() {
            match bytes_res {
                Ok(mut bytes) => all_bytes.append(&mut bytes),
                Err(err) => {
                    return Err(err);
                }
            }
        }

        return Ok(all_bytes);
    }

Pipes a read stream into a write stream. After all data is transmitted, both streams are closed.

Reads and returns all data from the stream until the end of stream.

This method does not close the stream.

Examples found in repository?
src/fetch_response.rs (line 51)
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    pub fn read_body(&mut self) -> Result<Vec<u8>, StreamError> {
        let result = self.read_stream.read_all();
        let closed = self.read_stream.close();

        if result.is_err() {
            return result;
        }

        if closed.is_err() {
            return Err(closed.err().unwrap());
        }

        return result;
    }
More examples
Hide additional examples
src/storage_response.rs (line 67)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    pub fn read_body(&mut self) -> Result<Vec<u8>, StreamError> {
        let result = self.read_stream.read_all();
        let closed = self.read_stream.close();

        if result.is_err() {
            return result;
        }

        if closed.is_err() {
            return Err(closed.err().unwrap());
        }

        return result;
    }

Trait Implementations§

Get the stream descriptor of this stream
Cleanly close the stream
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.