Skip to content

Commit a3b26cc

Browse files
committed
der: change GeneralStringRef.inner to BytesRef
1 parent 36e100b commit a3b26cc

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

der/src/asn1/general_string.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
use crate::{BytesRef, DecodeValue, EncodeValue, FixedTag, Header, Length, Reader, Tag, Writer};
22

3-
/// This is currently `OctetStringRef` internally, as `GeneralString` is not fully implemented yet
3+
/// This is currently `&[u8]` internally, as `GeneralString` is not fully implemented yet
44
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
55
pub struct GeneralStringRef<'a> {
66
/// Raw contents, unchecked
7-
#[doc(hidden)]
8-
pub __contents: &'a [u8],
7+
inner: BytesRef<'a>,
98
}
9+
impl<'a> GeneralStringRef<'a> {
10+
/// This is currently `&[u8]` internally, as `GeneralString` is not fully implemented yet
11+
pub fn as_bytes(&self) -> &'a [u8] {
12+
self.inner.as_slice()
13+
}
14+
}
15+
1016
impl FixedTag for GeneralStringRef<'_> {
1117
const TAG: Tag = Tag::GeneralString;
1218
}
@@ -15,16 +21,16 @@ impl<'a> DecodeValue<'a> for GeneralStringRef<'a> {
1521

1622
fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> Result<Self, Self::Error> {
1723
Ok(Self {
18-
__contents: BytesRef::decode_value(reader, header)?.as_slice(),
24+
inner: BytesRef::decode_value(reader, header)?,
1925
})
2026
}
2127
}
2228
impl EncodeValue for GeneralStringRef<'_> {
2329
fn value_len(&self) -> crate::Result<Length> {
24-
BytesRef::new(self.__contents)?.value_len()
30+
self.inner.value_len()
2531
}
2632

2733
fn encode_value(&self, encoder: &mut impl Writer) -> crate::Result<()> {
28-
BytesRef::new(self.__contents)?.encode_value(encoder)
34+
self.inner.encode_value(encoder)
2935
}
3036
}

gss-api/src/negotiation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ mod tests {
383383
);
384384
assert_eq!(
385385
b"not_defined_in_RFC4178@please_ignore",
386-
&neg_token.neg_hints.unwrap().hint_name.unwrap().__contents
386+
&neg_token.neg_hints.unwrap().hint_name.unwrap().as_bytes()
387387
);
388388
}
389389

0 commit comments

Comments
 (0)