crowdstrike_cloudproto/services/
lfo.rs1mod client;
4mod file_header;
5mod pkt_kind;
6mod request;
7mod response;
8
9use bytes::Bytes;
10pub use client::LfoClient;
11pub use file_header::{CompressionFormats, LfoFileHeader};
12pub use request::LfoRequest;
13pub use response::LfoResponse;
14
15use crate::framing::CloudProtoError;
16use thiserror::Error;
17
18#[derive(Error, Debug)]
19pub enum LfoError {
20 #[error("Requested file not found")]
21 NotFound,
22 #[error("Invalid LFO request")]
23 InvalidRequest,
24 #[error("{0}")]
25 ServerError(String),
26 #[error("Received LFO reply packet with kind {0}, but expected ReplyOk or ReplyFail")]
27 BadReplyKind(u8),
28 #[error("Failed to parse LFO reply: {reason}")]
29 ReplyParseError { reason: String, raw_payload: Bytes },
30 #[error("LFO data has final size {actual}, but expected {expected}")]
31 InvalidFinalSize { expected: usize, actual: usize },
32 #[error("LFO data has an invalid hash, it may be corrupt")]
33 InvalidHash {
34 expected: [u8; 32],
35 actual: [u8; 32],
36 },
37 #[error(transparent)]
38 CloudProto(#[from] CloudProtoError),
39}
40
41impl From<std::io::Error> for LfoError {
42 fn from(e: std::io::Error) -> Self {
43 Self::CloudProto(CloudProtoError::Io { source: e })
44 }
45}
46
47#[cfg(test)]
48mod test {
49 pub(crate) const TEST_REPLY_DATA: &str = "00000000000000d4a330869acb341ad81b4b64f92ed7b85e0a361ab0449017a9f7a5f09276a436550000aaaaaaaa01002200000003000000000002000000c800\
51 0000ac00000003000800010000000c00000003000000020000001c000000280000000000000038000000940000007800790058ff61006e000000416263644566\
52 4768696a6b6c4d000000002f1100005c110001470e00014715000158160001470e00015c030001450400007cffff002f0500005c050005000800014d0600012e\
53 070001410c00014d0d0003000100007cffff002f0800005c08000500110001410f0001451000a00000001c0000000c00000001000000bc000000000000007fc1\
54 f36f";
55}