Crate fancp

Source
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§

  • Types of ADJ (adjust) FCP requests.
  • Crate specific (not FCP bound) errors that may be returned trying to parse Requests.
  • Types of GET FCP requests.
  • Types of FCP requests.
  • Types of SET FCP requests.