Crates.io | doip-codec |
lib.rs | doip-codec |
version | |
source | src |
created_at | 2024-12-11 18:32:51.477777 |
updated_at | 2024-12-11 18:32:51.477777 |
description | Diagnostics over Internet Protocol codec for client-server communication. |
homepage | |
repository | https://github.com/samp-reston/doip-codec |
max_upload_size | |
id | 1480429 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
The Doip Codec
crate provides a DoipCodec
implementation for encoding and decoding Diagnostics Over Internet Protocol (DoIP) messages. It is designed to integrate seamlessly with the Tokio ecosystem, leveraging tokio-util
's Framed
for efficient stream-based reading and writing of DoIP messages.
Add the following to your Cargo.toml
:
[dependencies]
doip-codec = "1.0.0"
Then, include the crate in your code:
use doip_codec::DoipCodec;
Here's a simple example to get started with DoipCodec
:
use doip::{
header::{
payload::vehicle_identification_request::VehicleIdentificationRequest, version::DoipVersion,
},
message::message::DoipMessage,
};
use futures::{SinkExt, StreamExt};
use tokio::net::TcpStream;
use tokio_util::codec::Framed;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to a DoIP server
let stream = TcpStream::connect("127.0.0.1:13400").await?;
// Wrap the stream with the DoipCodec
let mut framed = Framed::new(stream, DoipCodec);
// Send a DoIP message
let request = DoipMessage::new(
DoipVersion::Iso13400_2012,
Box::new(VehicleIdentificationRequest {}),
); // Example payload
framed.send(request).await?;
// Receive a DoIP message
if let Some(response) = framed.next().await {
match response {
Ok(msg) => println!("Received message: {:?}", msg),
Err(e) => eprintln!("Failed to decode message: {}", e),
}
}
Ok(())
}
Comprehensive API documentation is available on docs.rs.
Diagnostics Over Internet Protocol (DoIP) is a modern diagnostic communication protocol that leverages IP-based networks for vehicle diagnostics, making it a critical component in automotive software. The Doip Codec
crate simplifies the implementation of DoIP messaging for Rust developers.
Contributions are welcome! Feel free to open issues, submit pull requests, or suggest features. Please follow the Rust Code of Conduct when contributing.
This project is licensed under the MIT License. See the LICENSE file for details.