1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use serde::{Deserialize, Serialize};
/// Opaque binary payload returned by binary tsgo endpoints.
///
/// # Examples
///
/// ```
/// use corsa_client::EncodedPayload;
///
/// let payload = EncodedPayload::new(vec![1, 2, 3]);
/// assert_eq!(payload.as_bytes(), &[1, 2, 3]);
/// assert_eq!(payload.clone().into_bytes(), vec![1, 2, 3]);
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EncodedPayload(Vec<u8>);
impl EncodedPayload {
/// Wraps raw bytes returned by tsgo.
pub fn new(bytes: Vec<u8>) -> Self {
Self(bytes)
}
/// Borrows the payload as a byte slice.
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
/// Consumes the wrapper and returns the underlying bytes.
pub fn into_bytes(self) -> Vec<u8> {
self.0
}
}
/// Formatting knobs accepted by the `printNode` endpoint.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct PrintNodeOptions {
/// Preserve original source newlines where the printer can do so safely.
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub preserve_source_newlines: bool,
/// Avoid ASCII-escaping non-ASCII characters in emitted text.
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub never_ascii_escape: bool,
/// Force literal termination when the source text would otherwise be
/// unterminated.
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub terminate_unterminated_literals: bool,
}