stalwartlabs / jmap-client

JMAP client library for Rust
Apache License 2.0
62 stars 8 forks source link

How do I send a Foo/get request? #8

Closed WhyNotHugo closed 1 year ago

WhyNotHugo commented 1 year ago

I'm trying to implement a JMAP client to synchronise calendars on a JMAP server. I'm basing my work on the current JMAP calendar draft.

I can't figure out how to use this library to execute a Foo/get request (e.g.: as described in rfc8620#section-5.1).

Do you have any pointers or examples or references that might help here? I've looked at jmap_client::core::get and jmap_client::Get, but I don't quite understand how these are meant to be used.

mdecimus commented 1 year ago

The Foo object does not exist in JMAP, it is used to demonstrate how the /get method works.

WhyNotHugo commented 1 year ago

I understand that Foo is an example/placeholder, and it is used with the same intent in my own question.

I guess a proper phrasing is "Given a theoretical object type called Foo, how do I fetch all instances of Foo"? Foo can be anything like Thread or Calendar or CalendarEvent (the latter two are the ones I'm interested in specifically).

mdecimus commented 1 year ago

That is not possible, the library does not offer a generic way to retrieve JMAP objects. Objects received from the JMAP server are deserialized using serde, so you'll have to implement the Calendar and CalendarEvent structures, make them de/serializable and finally write all the helper methods.

There are plans to support Calendar, Contacts and Tasks once the specifications are published.

WhyNotHugo commented 1 year ago

Just to make sure that I'm understanding correctly, the lower level API is not public at all? Are there any plans to make that public, or is that a non-goal?

mdecimus commented 1 year ago

There is no lower API. As you may know, JMAP is basically JSON structures sent over HTTP. This library is simply a collection of methods that convert Rust structures into JSON using serde which are then transferred over HTTP using the reqwest crate.

WhyNotHugo commented 1 year ago

Thanks for clarifying this. I see then that there's nothing for me to re-use here for a calendar implementation; I'd have to implement my own lower-level client first and then build the calendar implementation upon that.