AttrReadEncoder: If buffer is full, leave behind a sane state
Also, create an API that can be used to query the buffer full situation
This commit is contained in:
parent
e15920b839
commit
4f31cbf329
1 changed files with 12 additions and 1 deletions
|
@ -376,6 +376,7 @@ pub struct AttrReadEncoder<'a, 'b, 'c> {
|
||||||
path: GenericPath,
|
path: GenericPath,
|
||||||
skip_error: bool,
|
skip_error: bool,
|
||||||
data_ver_filters: Option<&'a TLVArray<'a, DataVersionFilter>>,
|
data_ver_filters: Option<&'a TLVArray<'a, DataVersionFilter>>,
|
||||||
|
is_buffer_full: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'c> AttrReadEncoder<'a, 'b, 'c> {
|
impl<'a, 'b, 'c> AttrReadEncoder<'a, 'b, 'c> {
|
||||||
|
@ -386,6 +387,7 @@ impl<'a, 'b, 'c> AttrReadEncoder<'a, 'b, 'c> {
|
||||||
skip_error: false,
|
skip_error: false,
|
||||||
path: Default::default(),
|
path: Default::default(),
|
||||||
data_ver_filters: None,
|
data_ver_filters: None,
|
||||||
|
is_buffer_full: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,6 +406,10 @@ impl<'a, 'b, 'c> AttrReadEncoder<'a, 'b, 'c> {
|
||||||
pub fn set_path(&mut self, path: GenericPath) {
|
pub fn set_path(&mut self, path: GenericPath) {
|
||||||
self.path = path;
|
self.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_buffer_full(&self) -> bool {
|
||||||
|
self.is_buffer_full
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b, 'c> Encoder for AttrReadEncoder<'a, 'b, 'c> {
|
impl<'a, 'b, 'c> Encoder for AttrReadEncoder<'a, 'b, 'c> {
|
||||||
|
@ -413,7 +419,12 @@ impl<'a, 'b, 'c> Encoder for AttrReadEncoder<'a, 'b, 'c> {
|
||||||
ib::AttrPath::new(&self.path),
|
ib::AttrPath::new(&self.path),
|
||||||
value,
|
value,
|
||||||
));
|
));
|
||||||
let _ = resp.to_tlv(self.tw, TagType::Anonymous);
|
|
||||||
|
let anchor = self.tw.get_tail();
|
||||||
|
if resp.to_tlv(self.tw, TagType::Anonymous).is_err() {
|
||||||
|
self.is_buffer_full = true;
|
||||||
|
self.tw.rewind_to(anchor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_status(&mut self, status: IMStatusCode, cluster_status: u16) {
|
fn encode_status(&mut self, status: IMStatusCode, cluster_status: u16) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue