-
Notifications
You must be signed in to change notification settings - Fork 57
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
Type Any #194
Comments
So, type
a) You can simply parse the fully qualified name of the type from the last part of b) The docs mention type-servers that you can hit with I think we can support a) by providing a custom decode method for Let's say there is a struct module A module B struct C; x::Int end end end Then, you can do e.g. the following to get the Julia type from a url_string: function type_from_type_url(x)
m::Module = @__MODULE__
i = findlast('/', x)
@assert !isnothing(i)
@inbounds while true
j = findnext('.', x, i+1)
isnothing(j) && return getfield(m, Symbol(@view x[i+1:end]))
m = getfield(m, Symbol(view(x, i+1:j-1)))::Module
i = j
end
end
get_from_module_manual("abcd/efgh/x/A.B.C")(1)
# Main.A.B.C(1)
# benchmark: 364.380 ns (1 allocation: 16 bytes) With this, we could provide a special function decode(d::AbstractProtoDecoder, x::Type{var"#Any"})
any_message = _decode_any_type(d)
T = type_from_type_url(any_message.type_url)
return decode(ProtoDecoder(IOBuffer(any_message.value)), T)
end For b), IMO, a lot more design work is needed. We'd need to fetch the Frankly, I think it would be better to only support |
Can you insert another ProtoBuf message inside a field of type Any? If so, how?
The google doc refers that this depends on the target language.
The text was updated successfully, but these errors were encountered: