Skip to main content

Crate rsomeip_proto

Crate rsomeip_proto 

Source
Expand description

§rsomeip-proto

Sans-IO implementation of the SOME/IP protocol.

§Overview

This crate provides an implementation of the core SOME/IP protocol, mainly focused on message processing.

It provides the basic primitives used by the protocol as well as endpoint and interface abstractions to check messages for correctness.

§Features

  • tp: Implementation of the SOME/IP Transport Protocol for segmenting large messages.

§Getting Started

  1. Add rsomeip-proto as a dependency to your project.

    # Cargo.toml
    
    [dependencies]
    rsomeip-proto = "0.1.0"
  2. Create an Endpoint and serve an Interface. Use the Endpoint::process and Endpoint::poll methods to serialize and deserialize messages.

    use rsomeip_proto::{Endpoint, ServiceId, Interface, MethodId, MessageType};
    use rsomeip_bytes::{Bytes, BytesMut};
    
    type Message = rsomeip_proto::Message<Bytes>;
    
    // Create an endpoint with a stub and a proxy.
    let endpoint = Endpoint::new()
        .with_interface(
            ServiceId::new(0x0001),
            Interface::default().with_method(MethodId::default()),
        )
        .with_interface(
            ServiceId::new(0x0002),
            Interface::default().with_method(MethodId::default()).into_proxy(),
        );
    
    // Poll for incoming messages.
    let mut buffer = Message::default()
        .with_service(ServiceId::new(0x0001))
        .to_bytes()
        .expect("should serialize the message");
    assert_eq!(
        endpoint.poll(&mut buffer),
        Ok(Message::default().with_service(ServiceId::new(0x0001)))
    );
    
    // Process outgoing messages.
    let mut buffer = BytesMut::with_capacity(16);
    assert_eq!(
        endpoint.process(
            Message::default().with_service(ServiceId::new(0x0002)),
            &mut buffer
        ),
        Ok(16)
    );
    assert_eq!(
        buffer.freeze(),
        Message::default()
            .with_service(ServiceId::new(0x0002))
            .to_bytes()
            .expect("should serialize")
    );

§Motivation

This crate is intended to be used as the core for developing more complex crates based on the SOME/IP protocol.

§License

This project is licensed under either the Apache-2.0 License or MIT License, at your option.

§Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Structs§

ClientId
Unique identifier of the client of a service interface.
Endpoint
Collection of SOME/IP service interfaces.
GenericMessage
Message addressed to a service instance.
Header
Header of a SOME/IP message.
Interface
SOME/IP service interface.
InterfaceVersion
Major version of a service interface.
MessageId
Unique identifier of a method or event on a service interface.
MessageTypeField
MessageType and associated flags packed into a single byte.
MethodId
Unique identifier of a method, field or event on a service interface.
ProtocolVersion
Major version of the SOME/IP protocol.
RequestId
Unique identifier of message to a service interface.
ServiceId
Unique identifier of a service interface.
SessionId
Unique identifier of a sequential message or request.

Enums§

EndpointError
Represents an error during Endpoint operations.
InterfaceType
The type of a SOME/IP service interface.
MessageType
Type of a SOME/IP message.
MethodType
The type of a SOME/IP method.
ReturnCode
Result of processing a SOME/IP request.

Type Aliases§

Message
SOME/IP message, Protocol Version 1.