Home
last modified time | relevance | path

Searched refs:buf (Results 1 – 25 of 126) sorted by relevance

123456

/commonlibrary/ets_utils/js_api_module/buffer/test/
Dtest_napi.cpp39 void FillZero(OHOS::buffer::Buffer *buf, size_t size) in FillZero() argument
42 buf->Set(i, 0); in FillZero()
54 OHOS::buffer::Buffer *buf = new OHOS::buffer::Buffer(); variable
55 buf->Init(10);
56 ASSERT_EQ(buf->GetLength(), 10);
118 OHOS::buffer::Buffer *buf = new OHOS::buffer::Buffer(); variable
119 buf->Init(1);
120 ASSERT_EQ(buf->GetLength(), 1);
121 uint32_t res = buf->Copy(nullptr, 0, 0, 0);
123 int result = buf->Compare(nullptr, 0, 0, 0);
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/tests/
Dasync_fs.rs32 let buf = "hello".as_bytes().to_vec(); in sdv_async_fs_write() localVariable
33 let res = file.write(&buf).await.unwrap(); in sdv_async_fs_write()
41 let mut buf = [0; 5]; in sdv_async_fs_write() localVariable
42 let res = file.read(&mut buf).await.unwrap(); in sdv_async_fs_write()
44 assert_eq!(&buf, "hello".as_bytes()); in sdv_async_fs_write()
60 let buf = vec![1, 2, 3, 4, 5]; in sdv_async_fs_read() localVariable
61 let res = file.write(&buf).await.unwrap(); in sdv_async_fs_read()
66 let mut buf = [0; 5]; in sdv_async_fs_read() localVariable
67 let res = file.read(&mut buf).await.unwrap(); in sdv_async_fs_read()
69 assert_eq!(buf, [1, 2, 3, 4, 5]); in sdv_async_fs_read()
[all …]
Dtcp_test.rs75 let mut buf = [0_u8; 12]; in sdv_tcp_global_runtime() localVariable
76 let _ = match socket.read(&mut buf).await { in sdv_tcp_global_runtime()
80 std::str::from_utf8(&buf).unwrap(), in sdv_tcp_global_runtime()
111 let mut buf = [0; 100]; in sdv_tcp_multi_runtime() localVariable
112 stream.read_exact(&mut buf).await.unwrap(); in sdv_tcp_multi_runtime()
113 assert_eq!(buf, [3; 100]); in sdv_tcp_multi_runtime()
115 let buf = [2; 100]; in sdv_tcp_multi_runtime() localVariable
116 stream.write_all(&buf).await.unwrap(); in sdv_tcp_multi_runtime()
126 let buf = [3; 100]; in sdv_tcp_multi_runtime() localVariable
127 tcp.write_all(&buf).await.unwrap(); in sdv_tcp_multi_runtime()
[all …]
Dasync_buf_write.rs35 let mut buf = [0; 6]; in sdv_buf_writer_write() localVariable
36 let ret = stream.read(&mut buf).await.unwrap(); in sdv_buf_writer_write()
38 assert_eq!(buf, [1, 2, 3, 4, 5, 6]); in sdv_buf_writer_write()
48 let buf = [1, 2, 3, 4, 5, 6]; in sdv_buf_writer_write() localVariable
51 buf_writer.write(&buf).await.unwrap(); in sdv_buf_writer_write()
74 let mut buf = [0; 17]; in sdv_buf_writer_write_vectored() localVariable
75 let ret = stream.read(&mut buf).await.unwrap(); in sdv_buf_writer_write_vectored()
77 assert_eq!(buf, "lorem-ipsum-dolor".as_bytes()); in sdv_buf_writer_write_vectored()
118 let buf = "lorem-ipsum-dolor".as_bytes(); in sdv_buf_writer_seek() localVariable
119 let res = file.write(buf).await.unwrap(); in sdv_buf_writer_seek()
[all …]
Dasync_buf_read.rs42 let mut buf = [0; 4]; in sdv_buf_reader_read_until() localVariable
43 let ret = buf_reader.read(&mut buf).await.unwrap(); in sdv_buf_reader_read_until()
45 assert_eq!(buf, [4, 5, 6, 0]); in sdv_buf_reader_read_until()
55 let buf = [1, 2, 3, b':', 4, 5, 6]; in sdv_buf_reader_read_until() localVariable
56 tcp.write_all(&buf).await.unwrap(); in sdv_buf_reader_read_until()
97 let buf = "World\nline".as_bytes(); in sdv_buf_reader_read_line() localVariable
98 tcp.write_all(buf).await.unwrap(); in sdv_buf_reader_read_line()
136 let buf = "lorem-ipsum-dolor".as_bytes(); in sdv_buf_reader_split() localVariable
137 tcp.write_all(buf).await.unwrap(); in sdv_buf_reader_split()
184 let buf = "lorem\r\nipsum\ndolor".as_bytes(); in sdv_buf_reader_lines() localVariable
[all …]
Dasync_read.rs32 let mut buf = [0; 5]; in sdv_async_read_slice() localVariable
35 let res = AsyncReadExt::read(&mut slice.as_slice(), &mut buf) in sdv_async_read_slice()
39 assert_eq!(buf, [1, 2, 3, 0, 0]); in sdv_async_read_slice()
42 let mut buf = [0; 2]; in sdv_async_read_slice() localVariable
44 let res = AsyncReadExt::read(&mut slice.as_slice(), &mut buf) in sdv_async_read_slice()
48 assert_eq!(buf, [1, 2]); in sdv_async_read_slice()
81 let buf = [87, 111, 114, 108, 100]; in sdv_buf_reader_read_to_string() localVariable
82 tcp.write_all(&buf).await.unwrap(); in sdv_buf_reader_read_to_string()
/commonlibrary/rust/ylong_runtime/ylong_runtime/src/fs/
Dfile_buf.rs20 pub(crate) buf: Vec<u8>, field
30 buf: Vec::with_capacity(n), in with_capacity()
36 self.buf.len() - self.idx in remaining()
39 pub(crate) fn append_to(&mut self, buf: &mut ReadBuf<'_>) -> usize { in append_to()
40 let n = std::cmp::min(self.remaining(), buf.remaining()); in append_to()
42 buf.append(&self.buf[self.idx..r_idx]); in append_to()
44 if r_idx == self.buf.len() { in append_to()
46 self.buf.truncate(0); in append_to()
56 self.buf.extend_from_slice(&other[..n]); in append()
64 self.buf.reserve(len.saturating_sub(self.buf.len())); in reserve()
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/src/io/buffered/
Dasync_buf_writer.rs34 buf: Vec<u8>, field
75 buf: Vec::with_capacity(cap), in with_capacity()
145 &self.buf in buffer()
170 self.buf.capacity() in capacity()
175 let len = this.buf.len(); in flush()
180 Pin::new_unchecked(&mut this.inner).poll_write(cx, &this.buf[this.written..]) in flush()
198 this.buf.drain(..this.written); in flush()
209 buf: &[u8], in poll_write()
211 if self.buf.len() + buf.len() > self.buf.capacity() { in poll_write()
216 if buf.len() >= this.buf.capacity() { in poll_write()
[all …]
/commonlibrary/rust/ylong_http/ylong_http/src/body/
Dtext.rs205 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
206 Read::read(&mut *self.from, buf) in data()
216 buf: &mut [u8], in poll_data()
218 Poll::Ready(Read::read(&mut *self.from, buf)) in poll_data()
225 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
226 self.from.read(buf) in data()
236 buf: &mut [u8], in poll_data()
238 let mut buf = ReadBuf::new(buf); in poll_data() localVariable
239 match Pin::new(&mut *self.from).poll_read(cx, &mut buf) { in poll_data()
240 Poll::Ready(Ok(())) => Poll::Ready(Ok(buf.filled().len())), in poll_data()
[all …]
Dchunk.rs224 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
226 while count != buf.len() { in data()
228 DataState::Partial => self.bytes_encode(&mut buf[count..]), in data()
229 DataState::Complete => self.trailer_encode(&mut buf[count..]), in data()
234 Ok(buf.len()) in data()
241 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
243 while count != buf.len() { in data()
252 self.chunk_encode(&mut buf[count..]) in data()
254 DataState::Complete => self.trailer_encode(&mut buf[count..]), in data()
261 Ok(buf.len()) in data()
[all …]
Dmod.rs155 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>; in data()
166 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
167 self.read(buf) in data()
229 buf: &mut [u8], in poll_data()
289 fn data<'a, 'b>(&'a mut self, buf: &'b mut [u8]) -> DataFuture<'a, 'b, Self> in data()
294 DataFuture { body: self, buf } in data()
314 buf: &'b mut [u8], field
325 Pin::new(&mut *fut.body).poll_data(cx, fut.buf) in poll()
333 buf: &mut [u8], in poll_read()
335 let mut read_buf = ReadBuf::new(buf); in poll_read()
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/src/io/
Dread_buf.rs31 pub(crate) buf: &'a mut [MaybeUninit<u8>], field
39 pub fn new(buf: &'a mut [u8]) -> ReadBuf<'a> { in new()
41 buf: unsafe { &mut *(buf as *mut [u8] as *mut [MaybeUninit<u8>]) }, in new()
43 initialized: buf.len(), in new()
50 buf: &'a mut [MaybeUninit<u8>], in create()
55 buf, in create()
63 pub fn uninit(buf: &mut [MaybeUninit<u8>]) -> ReadBuf<'_> { in uninit()
65 buf, in uninit()
74 self.buf.len() in capacity()
100 unsafe { &*(&self.buf[..self.filled] as *const [MaybeUninit<u8>] as *const [u8]) } in filled()
[all …]
Dread_task.rs42 buf: &'a mut [u8], field
47 pub(crate) fn new(reader: &'a mut R, buf: &'a mut [u8]) -> ReadTask<'a, R> { in new()
50 buf, in new()
64 let mut buf = ReadBuf::new(self.buf); in poll() localVariable
65 match Pin::new(&mut reader).poll_read(cx, &mut buf) { in poll()
67 Poll::Ready(_) => Poll::Ready(Ok(buf.filled_len())), in poll()
81 buf: &'a mut Vec<u8>, field
87 pub(crate) fn new(reader: &'a mut R, buf: &'a mut Vec<u8>) -> ReadToEndTask<'a, R> { in new()
90 buf, in new()
97 buf: &mut Vec<u8>, in poll_read_to_end()
[all …]
Dasync_read.rs44 buf: &mut ReadBuf<'_>, in poll_read()
53 buf: &mut ReadBuf<'_>, in poll_read()
55 Pin::new(&mut **self).poll_read(cx, buf) in poll_read()
64 buf: &mut ReadBuf<'_>, in poll_read()
66 Pin::new(&mut **self).poll_read(cx, buf) in poll_read()
79 buf: &mut ReadBuf<'_>, in poll_read()
81 self.get_mut().as_mut().poll_read(cx, buf) in poll_read()
111 fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadTask<'a, Self> { in read()
112 ReadTask::new(self, buf) in read()
130 fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactTask<'a, Self> { in read_exact()
[all …]
/commonlibrary/rust/ylong_http/ylong_http/src/body/mime/common/
Dheaders.rs160 buf: &'a [u8], in decode()
162 if buf.is_empty() { in decode()
167 let mut remains = buf; in decode()
189 fn start_decode<'a>(&mut self, buf: &'a [u8]) -> Result<&'a [u8], HttpError> { in start_decode()
190 let buf = if self.src.is_empty() { in start_decode() localVariable
191 trim_front_lwsp(buf) in start_decode()
193 buf in start_decode()
197 match buf[0] { in start_decode()
201 } else if buf.len() == 1 { in start_decode()
204 } else if buf[1] == LF { in start_decode()
[all …]
Dmod.rs74 pub(crate) fn data_copy(src: &[u8], src_idx: &mut usize, buf: &mut [u8]) -> TokenResult<usize> { in data_copy()
76 let output_len = buf.len(); in data_copy()
78 let num = (&src[*src_idx..]).read(buf)?; in data_copy()
87 pub(crate) fn trim_front_lwsp(buf: &[u8]) -> &[u8] { in trim_front_lwsp()
89 for b in buf.iter() { in trim_front_lwsp()
95 &buf[idx..] in trim_front_lwsp()
99 fn trim_back_lwsp(buf: &[u8]) -> &[u8] { in trim_back_lwsp()
101 for b in buf.iter().rev() { in trim_back_lwsp()
107 &buf[..buf.len() - idx] in trim_back_lwsp()
112 pub(crate) fn trim_back_lwsp_if_end_with_lf(buf: &[u8]) -> &[u8] { in trim_back_lwsp_if_end_with_lf()
[all …]
/commonlibrary/rust/ylong_http/ylong_http/src/h2/hpack/representation/
Ddecoder.rs28 buf: &'a [u8], field
35 pub(crate) fn new(buf: &'a [u8]) -> Self { in new()
36 Self { buf, state: None } in new()
48 if self.buf.is_empty() { in decode()
57 .decode(&mut self.buf) in decode()
102 fn decode(self, buf: &mut &[u8]) -> DecResult<$decoded, $name> {
105 Self::$state(state) => state.decode(buf),
168 fn decode(self, buf: &mut &[u8]) -> DecResult<Representation, ReprDecodeState> { in decode()
169 match self.inner.decode(buf) { in decode()
181 DecResult::Decoded((repr, 0)) => NameString::new(repr).decode(buf), in decode()
[all …]
/commonlibrary/rust/ylong_http/ylong_http/src/h2/
Dencoder.rs159 pub fn encode(&mut self, buf: &mut [u8]) -> Result<usize, FrameEncoderErr> { in encode()
162 while written_bytes < buf.len() { in encode()
170 let bytes = self.encode_headers_frame(&mut buf[written_bytes..])?; in encode()
177 let bytes = self.encode_headers_payload(&mut buf[written_bytes..])?; in encode()
184 let bytes = self.encode_padding(&mut buf[written_bytes..])?; in encode()
191 let bytes = self.encode_continuation_frames(&mut buf[written_bytes..])?; in encode()
198 let bytes = self.encode_data_header(&mut buf[written_bytes..])?; in encode()
205 let bytes = self.encode_data_payload(&mut buf[written_bytes..])?; in encode()
212 let bytes = self.encode_padding(&mut buf[written_bytes..])?; in encode()
219 let bytes = self.encode_settings_frame(&mut buf[written_bytes..])?; in encode()
[all …]
Ddecoder.rs222 fn hpack_decode(&mut self, buf: &[u8]) -> Result<(), H2Error> { in hpack_decode()
223 self.hpack.decode(buf) in hpack_decode()
348 pub fn decode(&mut self, buf: &[u8]) -> Result<Frames, H2Error> { in decode()
350 let mut buffer = buf; in decode()
379 buf: &'a [u8], in decode_frame_payload()
391 if buf.len() < frame_end_index { in decode_frame_payload()
392 self.offset += buf.len(); in decode_frame_payload()
393 self.buffer.extend_from_slice(buf); in decode_frame_payload()
397 0 => self.decode_data_payload(&buf[..frame_end_index])?, in decode_frame_payload()
398 1 => self.decode_headers_payload(&buf[..frame_end_index])?, in decode_frame_payload()
[all …]
/commonlibrary/rust/ylong_http/ylong_http/src/body/mime/decode/
Dpart.rs72 buf: &'a [u8], in decode()
75 if buf.is_empty() { in decode()
80 let mut remains = buf; in decode()
101 fn start_decode<'a>(&mut self, buf: &'a [u8]) -> Result<&'a [u8], HttpError> { in start_decode()
102 let buf = trim_front_lwsp(buf); in start_decode() localVariable
104 Ok(buf) in start_decode()
108 fn headers_decode<'a>(&mut self, buf: &'a [u8]) -> Result<&'a [u8], HttpError> { in headers_decode()
109 let (elem, rest) = self.headers_decoder.decode(buf)?; in headers_decode()
119 fn body_decode<'a>(&mut self, buf: &'a [u8]) -> Result<&'a [u8], HttpError> { in body_decode()
120 match get_crlf_contain(buf) { in body_decode()
[all …]
Dmulti.rs117 buf: &'a [u8], in decode()
119 if buf.is_empty() { in decode()
124 let mut remains = buf; in decode()
155 buf: &'a [u8], in unknown_decode()
157 let (elem, rest) = headers_decoder.decode(buf)?; in unknown_decode()
200 buf: &'a [u8], in part_decode()
202 let (elem, rest) = part_decoder.decode(buf)?; in part_decode()
222 fn multi_decode<'a>(&mut self, data: DecodeData, buf: &'a [u8]) -> Result<&'a [u8], HttpError> { in multi_decode()
224 true => self.middle_or_end_boundary_decode(data, buf), in multi_decode()
225 false => self.first_boundary_decode(data, buf), in multi_decode()
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/benches/
Dylong_tokio_tcp.rs29 let mut buf = [0; $buf_size]; localVariable
30 stream.read_exact(&mut buf).await.unwrap();
31 assert_eq!(buf, [3; $buf_size]);
33 let buf = [2; $buf_size]; localVariable
34 stream.write_all(&buf).await.unwrap();
45 let buf = [3; $buf_size]; localVariable
46 tcp.write_all(&buf).await.unwrap();
48 let mut buf = [0; $buf_size]; localVariable
49 tcp.read_exact(&mut buf).await.unwrap();
50 assert_eq!(buf, [2; $buf_size]);
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/src/net/sys/tcp/
Dsplit.rs33 buf: &mut ReadBuf<'_>, in poll_read()
35 self.0.source.poll_read(cx, buf) in poll_read()
43 buf: &[u8], in poll_write()
45 self.0.source.poll_write(cx, buf) in poll_write()
79 buf: &mut ReadBuf<'_>, in poll_read()
81 self.0.source.poll_read(cx, buf) in poll_read()
89 buf: &[u8], in poll_write()
91 self.0.source.poll_write(cx, buf) in poll_write()
138 let mut buf = [0; 16]; in ut_test_borrow_half() localVariable
139 match stream.read(&mut buf).await { in ut_test_borrow_half()
[all …]
/commonlibrary/rust/ylong_runtime/ylong_runtime/examples/
Dylong_runtime_tcp.rs28 let mut buf = [0; BUF_SIZE]; in ylong_tcp_server() localVariable
29 stream.read_exact(&mut buf).await.unwrap(); in ylong_tcp_server()
30 assert_eq!(buf, [3; BUF_SIZE]); in ylong_tcp_server()
32 let buf = [2; BUF_SIZE]; in ylong_tcp_server() localVariable
33 stream.write_all(&buf).await.unwrap(); in ylong_tcp_server()
44 let buf = [3; BUF_SIZE]; in ylong_tcp_client() localVariable
45 tcp.write_all(&buf).await.unwrap(); in ylong_tcp_client()
47 let mut buf = [0; BUF_SIZE]; in ylong_tcp_client() localVariable
48 tcp.read_exact(&mut buf).await.unwrap(); in ylong_tcp_client()
49 assert_eq!(buf, [2; BUF_SIZE]); in ylong_tcp_client()
/commonlibrary/rust/ylong_http/ylong_http/src/body/mime/encode/
Dmulti.rs283 fn data(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { in data()
285 while count != buf.len() { in data()
292 MultiStage::Crlf => self.crlf_encode(&mut buf[count..]), in data()
293 MultiStage::Dash => self.dash_encode(&mut buf[count..]), in data()
294 MultiStage::Boundary(boundary) => self.boundary_encode(&mut buf[count..], boundary), in data()
296 self.headers_encode(&mut buf[count..], headers_encoder) in data()
299 self.sync_mimepart_encode(&mut buf[count..], part_encoder) in data()
314 buf: &mut [u8], in poll_data()
317 while count != buf.len() { in poll_data()
324 MultiStage::Crlf => Poll::Ready(self.crlf_encode(&mut buf[count..])), in poll_data()
[all …]

123456