pub fn new<S1, S2, P>(name: S1, id: S2, intents: P) -> Result<(Self, SkillIn)>
    where
        S1: Into<String>,
        S2: Into<String>,
        P: AsRef<Path> + Clone,
    {
        let id_str = id.into();
        let payload = rmp_serde::to_vec_named(&MsgConnect {
            id: id_str.clone(),
            name: name.into(),
            vap_version: "Alpha".into(),
            unique_authentication_token: Some("".into()),
        })
        .expect("Failed to make initial payload, report this");

        let client = CoAPClient::new(Self::get_address())?;
        let resp = client.request_path(
            "vap/skillRegistry/connect",
            Method::Post,
            Some(payload),
            None,
        )?;

        match resp.message.header.code {
            MessageClass::Response(ResponseType::Created) => {
                let payload: MsgConnectResponse =
                    rmp_serde::from_read(Cursor::new(resp.message.payload)).unwrap();
                let (sender, receiver) = mpsc::channel(10);

                let mut skill = Self {
                    client,
                    id: id_str,
                    langs: payload.langs.into_iter().map(|l| l.into()).collect(),
                    sender,
                };

                skill.register_intents(intents)?;
                skill.register()?;

                Ok((skill, receiver))
            }
            _ => {
                panic!("ERROR")
            }
        }
    }
/// Creates a new skill, will also connect to the skill registry and register
/// itself so that it receives requests. Returns both itself and a channel
/// that you will use to receive events. This follows RAII and as as soon as
/// it is dropped will disconnect from the skill registry.
/// 
/// # Arguments
/// 
/// * `name` - A human-readable name for this skill
/// * `id` -  This skill id like 'com.my_company.my_skill'
/// * `intents` - Where are the skills stored
/// 
Creates a new skill, will also connect to the skill registry and register
itself so that it receives requests. Returns both itself and a channel
that you will use to receive events. This follows RAII and as as soon as
it is dropped will disconnect from the skill registry.
Creates a new skill will also connect to the skill registry and register itself so that it receives requests . Returns both itself and a channel that you will use to receive events . This follows RAII and as as soon as it is dropped will disconnect from the skill registry .
pub fn new<S1, S2, P>(name: S1, id: S2, intents: P) -> Result<(Self, SkillIn)>
    where
        S1: Into<String>,
        S2: Into<String>,
        P: AsRef<Path> + Clone,
    {
        let id_str = id.into();
        let payload = rmp_serde::to_vec_named(&MsgConnect {
            id: id_str.clone(),
            name: name.into(),
            vap_version: "Alpha".into(),
            unique_authentication_token: Some("".into()),
        })
        .expect("Failed to make initial payload, report this");
        let client = CoAPClient::new(Self::get_address())?;
        let resp = client.request_path(
            "vap/skillRegistry/connect",
            Method::Post,
            Some(payload),
            None,
        )?;
        match resp.message.header.code {
            MessageClass::Response(ResponseType::Created) => {
                let payload: MsgConnectResponse =
                    rmp_serde::from_read(Cursor::new(resp.message.payload)).unwrap();
                let (sender, receiver) = mpsc::channel(10);
                let mut skill = Self {
                    client,
                    id: id_str,
                    langs: payload.langs.into_iter().map(|l| l.into()).collect(),
                    sender,
                };
                skill.register_intents(intents)?;
                skill.register()?;
                Ok((skill, receiver))
            }
            _ => {
                panic!("ERROR")
            }
        }
    }
pub fn new < S1 , S2 , P > ( name : S1 , id : S2 , intents : P ) -> Result < ( Self , SkillIn ) > where S1 : Into < String > , S2 : Into < String > , P : AsRef < Path > + Clone , { let id_str = id . into ( ) ; let payload = rmp_serde :: to_vec_named ( & MsgConnect { id : id_str . clone ( ) , name : name . into ( ) , vap_version : " " . into ( ) , unique_authentication_token : Some ( " " . into ( ) ) , } ) . expect ( " " ) ; let client = CoAPClient :: new ( Self :: get_address ( ) ) ? ; let resp = client . request_path ( " " , Method :: Post , Some ( payload ) , None , ) ? ; match resp . message . header . code { MessageClass :: Response ( ResponseType :: Created ) => { let payload : MsgConnectResponse = rmp_serde :: from_read ( Cursor :: new ( resp . message . payload ) ) . unwrap ( ) ; let ( sender , receiver ) = mpsc :: channel ( 10 ) ; let mut skill = Self { client , id : id_str , langs : payload . langs . into_iter ( ) . map ( | l | l . into ( ) ) . collect ( ) , sender , } ; skill . register_intents ( intents ) ? ; skill . register ( ) ? ; Ok ( ( skill , receiver ) ) } _ => { panic ! ( " " ) } } }
Creates a new skill, will also connect to the skill registry and register
itself so that it receives requests.
Creates a new skill will also connect to the skill registry and register itself so that it receives requests .
name
S1
id
S2
intents
P