Crate fancp[][src]

Expand description

This crate provides types and methods for parsing/ creating FCP requests.

Examples

use fancp::{Request, AdjRequest, GetRequest, SetRequest};

// Imagine we have an incoming fcp request
// over some connection. We can parse the request like this.
let req= "GET all"; // the bytes we received over the connection
let req = Request::parse(req).unwrap();
assert_eq!(Request::Get(GetRequest::All), req);

// We can also use the string extension method:
let req: Request = "SET v500".parse().unwrap();
assert_eq!(Request::Set(SetRequest::Voltage(500)), req);

// On the client side, we may form requests like this:
let req = Request::Adj(AdjRequest::Voltage(-25));
let req_string= format!("{};", &req); // fcp requests are ';' terminated
assert_eq!("ADJ v-25;", req_string.as_str());

Enums

AdjRequest

Types of ADJ (adjust) FCP requests.

Error

Crate specific (not FCP bound) errors that may be returned trying to parse Requests.

GetRequest

Types of GET FCP requests.

Request

Types of FCP requests.

SetRequest

Types of SET FCP requests.