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

feat(jans-cedarling): create uniffi binding for cedarling with sample ios app using it #10816

Merged
merged 26 commits into from
Feb 18, 2025

Conversation

duttarnab
Copy link
Contributor

@duttarnab duttarnab commented Feb 9, 2025

closes #9432

Prepare


Description

Target issue

closes #issue-number-here

Implementation Details


Test and Document the changes

  • Static code analysis has been run locally and issues have been fixed
  • Relevant unit and integration tests have been added/updated
  • Relevant documentation has been updated if any (i.e. user guides, installation and configuration guides, technical design docs etc)

Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with docs: to indicate documentation changes or if the below checklist is not selected.

  • I confirm that there is no impact on the docs due to the code changes in this PR.

@mo-auto mo-auto added comp-jans-cedarling Touching folder /jans-cedarling kind-feature Issue or PR is a new feature request labels Feb 9, 2025
rmarinn
rmarinn previously approved these changes Feb 10, 2025
Copy link
Contributor

@nynymike nynymike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the Readme, but is there an impact on the docs?

Docs Added

@nynymike
Copy link
Contributor

I'd like @NazarYavornytskyy to review this PR, as he's the most experienced iOS developer on our team.

@olehbozhok
Copy link
Contributor

Actually I don't really understand name jcedarling_native_apps because it is not native implementation it is uniffi implementation.

@olehbozhok
Copy link
Contributor

Also, I see a lot of print in code. And I can't believe it is good approach for logging.

@olehbozhok
Copy link
Contributor

It is supposed to be Swift application or only lib to import to real application?

request_id: &str,
tag: &str,
) -> Result<Vec<String>, LogError> {
let mut result = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can allocate result with defined capacity. With length from result self.inner.get_logs_by_request_id_and_tag(request_id, tag)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// Return log entries that match the given request_id.
#[uniffi::method]
pub fn get_logs_by_request_id(&self, request_id: &str) -> Result<Vec<String>, LogError> {
let mut result = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can allocate result with defined capacity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/// Tag can be `log_kind`, `log_level`.
#[uniffi::method]
pub fn get_logs_by_tag(&self, tag: &str) -> Result<Vec<String>, LogError> {
let mut result = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can allocate result with defined capacity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

//Get all log ids
#[uniffi::method]
pub fn get_log_ids(&self) -> Vec<String> {
let mut result = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can allocate result with defined capacity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Retrieves logs and serializes them as JSON strings
#[uniffi::method]
pub fn pop_logs(&self) -> Result<Vec<String>, LogError> {
let mut result = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can allocate result with defined capacity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

crate_type = ["cdylib", "staticlib"]
name = "mobile"

[dependencies]
Copy link
Contributor

@olehbozhok olehbozhok Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid error in compile wasm tests you can use

# dependency for NOT wasm target
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

instead of [dependencies] like here

and don't forget to add this in lib.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@olehbozhok olehbozhok changed the title feat: initial commit for ios binding feat(jans-cedarling): initial commit for ios binding Feb 10, 2025
@duttarnab duttarnab dismissed stale reviews from NazarYavornytskyy and rmarinn via c981cd5 February 11, 2025 11:29

// Struct to hold authorization result, compatible with iOS serialization
#[derive(Debug, serde::Serialize, uniffi::Record)]
pub struct AuthorizeResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

nynymike
nynymike previously approved these changes Feb 16, 2025
nynymike
nynymike previously approved these changes Feb 17, 2025
) -> Result<Self, RequestError> {
// Validate tokens: ensure all values are non-empty after trimming
let mut validated_tokens = HashMap::new();
for (key, value) in tokens.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use tokens.into_iter(), and avoid cloning of key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

olehbozhok
olehbozhok previously approved these changes Feb 17, 2025
Copy link
Contributor

@olehbozhok olehbozhok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me.

@olehbozhok
Copy link
Contributor

You can use next code snippet to avoid cargo error

bindings/cedarling_uniffi/src/bin/uniffi-bindgen.rs

#[cfg(not(target_arch = "wasm32"))]
fn main() {
    uniffi::uniffi_bindgen_main()
}

// just to avoid clippy error about missing `main` function
#[cfg(target_arch = "wasm32")]
fn main() {
}

@duttarnab duttarnab dismissed stale reviews from olehbozhok and nynymike via 989d8ea February 18, 2025 08:29
@duttarnab duttarnab changed the title feat(jans-cedarling): initial commit for ios binding feat(jans-cedarling): create unifi bining for cedarling with sample ios app using it Feb 18, 2025
@duttarnab duttarnab changed the title feat(jans-cedarling): create unifi bining for cedarling with sample ios app using it feat(jans-cedarling): create uniffi bining for cedarling with sample ios app using it Feb 18, 2025
@duttarnab duttarnab changed the title feat(jans-cedarling): create uniffi bining for cedarling with sample ios app using it feat(jans-cedarling): create uniffi binding for cedarling with sample ios app using it Feb 18, 2025
@duttarnab duttarnab merged commit 026ed0b into main Feb 18, 2025
72 of 84 checks passed
@duttarnab duttarnab deleted the jans-cedarling-issue-9432_2 branch February 18, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-jans-cedarling Touching folder /jans-cedarling kind-feature Issue or PR is a new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(jans-cedarling): create ios binding for cedarling
6 participants