Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query task group state failed in rust. #270

Open
glen0125 opened this issue May 18, 2023 · 3 comments
Open

Query task group state failed in rust. #270

glen0125 opened this issue May 18, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@glen0125
Copy link
Member

When I query task group state in rust, it returns err: (InvalidFormat, parse json string error: value=Download, err: (InvalidParam, unknown trans group type: Download, None), None)

rust code:
stack.trans().get_task_group_state(TransGetTaskGroupStateOutputRequest { common: NDNOutputRequestCommon { req_path: None, dec_id: None, level: NDNAPILevel::Router, target: Some(ood_id.clone()), referer_object: vec![], flags: 0, }, group: group_id.clone(), group_type: TransTaskGroupType::Download, speed_when: None, }).await

@glen0125 glen0125 added the bug Something isn't working label May 18, 2023
@lurenpluto lurenpluto added this to the Group-supported Release milestone May 18, 2023
@lurenpluto
Copy link
Member

This should be caused by the inconsistency between the default serde codec format of the TransTaskGroupType enumeration type and the ToString trait implementation

Request initiation side (cyfs-lib)
TransGetTaskGroupStateOutputRequest uses the serde macro implementation

#[derive(Debug, Serialize, Deserialize)]
pub struct TransGetTaskGroupStateOutputRequest {
pub common: NDNOutputRequestCommon,
pub group_type: TransTaskGroupType,
pub group: String,
pub speed_when: Option<u64>,
}

Receiving request side (cyfs-stack)
TransGetTaskGroupStateInputRequest uses the older JsonCodec encoding, while the encoding of the TransTaskGroupType field here uses the FromString implementation, and required is all lowercase

So the problem is either that the FromtStr trait implementation of TransTaskGroupType is compatible with both forms of strings, or TransTaskGroupType needs to use a uniform encoding

@lurenpluto
Copy link
Member

The json encoding of TransTaskGroupType has been fixed using serde_with crate and is now based on the ToString(Display trait) and FromStr trait implementations, consistent with the JsonCodec implementation:

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr)]
pub enum TransTaskGroupType {
Download,
Upload
}

@glen0125
Copy link
Member Author

Great job, looking forward to using the new version soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🧪To Test
Development

No branches or pull requests

2 participants