Skip to content

Commit da343a4

Browse files
authored
ssh-encoding: fix string comments on encoding trait impls (#343)
The impls of `Decode` for `Bytes` and `Encode` for `[u8]` made reference to `byte[n]`, i.e. a fixed length bytestring, however both these types are analogues for `string`, which is encoded with a length prefix. The comments have been updated to reflect the correct type they map to in the SSH encoding schema, which is `string`.
1 parent 85f0c56 commit da343a4

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

ssh-encoding/src/decode.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,14 @@ impl Decode for Vec<String> {
179179
}
180180
}
181181

182-
/// Decodes `Bytes` from `byte[n]` as described in [RFC4251 § 5]:
182+
/// Decodes `Bytes` from `string` as described in [RFC4251 § 5]:
183183
///
184-
/// > A byte represents an arbitrary 8-bit value (octet). Fixed length
185-
/// > data is sometimes represented as an array of bytes, written
186-
/// > `byte[n]`, where n is the number of bytes in the array.
184+
/// > Arbitrary length binary string. Strings are allowed to contain
185+
/// > arbitrary binary data, including null characters and 8-bit
186+
/// > characters. They are stored as a uint32 containing its length
187+
/// > (number of bytes that follow) and zero (= empty string) or more
188+
/// > bytes that are the value of the string. Terminating null
189+
/// > characters are not used.
187190
///
188191
/// [RFC4251 § 5]: https://datatracker.ietf.org/doc/html/rfc4251#section-5
189192
#[cfg(feature = "bytes")]

ssh-encoding/src/encode.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,14 @@ impl Encode for usize {
134134
}
135135
}
136136

137-
/// Encodes `[u8]` into `byte[n]` as described in [RFC4251 § 5]:
137+
/// Encodes `[u8]` into `string` as described in [RFC4251 § 5]:
138138
///
139-
/// > A byte represents an arbitrary 8-bit value (octet). Fixed length
140-
/// > data is sometimes represented as an array of bytes, written
141-
/// > `byte[n]`, where n is the number of bytes in the array.
139+
/// > Arbitrary length binary string. Strings are allowed to contain
140+
/// > arbitrary binary data, including null characters and 8-bit
141+
/// > characters. They are stored as a uint32 containing its length
142+
/// > (number of bytes that follow) and zero (= empty string) or more
143+
/// > bytes that are the value of the string. Terminating null
144+
/// > characters are not used.
142145
///
143146
/// [RFC4251 § 5]: https://datatracker.ietf.org/doc/html/rfc4251#section-5
144147
impl Encode for [u8] {

0 commit comments

Comments
 (0)