Comments (6)
… that is, instead of being Option
al, it should have a default value when deserializing, like the limit
field in get_context
.
from ruma.
sync_events also has a struct with a field that should be updated in the same way.
from ruma.
Hi, I'm curious about the implementation.
Changing limit
field type from Option<UInt>
to UInt
will make it required from the perspective of the library consumer. Is it intended to be that way? I'm asking this under the assumption that ruma-client-api will be used by developer of rust-based matrix client. CMIIW and go easy on me because I'm new.
Anyway here's a fix #66
from ruma.
Yes, this means that client authors will have to write UInt::from(0u32)
where they could previously write None
. This loss of convenience can be tackled by authors of higher-level client libraries (e.g. matrix-rust-sdk
), although we're also planning to make construction of our types easier, by adding constructors to lots of our types; see #14.
from ruma.
I just thought that having a one-to-one mapping between Rust struct and its URI query component counterpart would reduce the programmer's cognitive load (in place of the struct being dumb)
Request { roomId: "some_room_id", from: "token", to: "token2", dir: Direction::backward, limit: None, filter: None }
=> ?from=token&to=token2&dir=b
Request { roomId: "some_room_id", from: "token", to: "token2", dir: Direction::backward, limit: Some(10), filter: None }
=> ?from=token&to=token2&dir=b&limit=0
I am assuming that the default: 10
part is already the server's responsibility. I haven't been able to find that it is actually the server's responsibility in the draft docs.
Also, having the client responsible for the default value, you might also want to expose the default value as public.
from ruma.
I am assuming that the
default: 10
part is already the server's responsibility.
It is. But since ruma-client-api can also be used for servers, it makes sense to encode these kinds of defaults in our code, so people building servers on top of our libraries don't have to care about it.
Also, having the client responsible for the default value, you might also want to expose the default value as public.
We could do that, yeah. I'd not be opposed to that, if post #14 being fixed somebody still has a clear use case for it.
By the way, that issue is something that will have to be tackled as lots of independent small changes – if you want, you can open a PR adding a constructor for the Request
you just modified (making it #[non_exhaustive]
has to be done in macro code, we'll figure out how to best do that separately), with only the fields that the spec requires as arguments, the rest being set to their default values.
from ruma.
Related Issues (20)
- Upgrade dependencies HOT 1
- Remove `keyId` from the server `/keys` endpoints (MSC3938)
- Consider not using Cargo workspace feature HOT 2
- URI Path encoding should only encode reserved characters
- Be consistent in character sets for percent encoding HOT 6
- `InitialStateEvent` doesn't implement `Serialize` anymore
- Allow selecting owned identifier memory representation via regular environment variable HOT 7
- OriginalSyncRoomMessageEvent is undocumented HOT 2
- `RoomVersionId` shouldn't allow characters outside of `a-z`, `0-9`, `.`, and `-`.
- Implement MSC3925 HOT 1
- Add support for MSC2399, new to_device event type `m.room_key.withheld`
- Implement Matrix v1.7 changes HOT 1
- Bug: empty localpart of a user ID is a valid localpart
- Be able to interpret `unstable_features`
- JsonWebKey should be independent of Ruma HOT 3
- set_pushrule request uses the wrong HTTP method (GET instead of PUT) HOT 3
- Implement `AsRef<T> for T` for borrowed identifier types
- Why are CustomEventContent fields private? HOT 3
- Error parsing error response for `POST /_matrix/client/v3/keys/signatures/upload` HOT 5
- Make DST ID types less awkward under the `Arc` ID representation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruma.