Skip to content

Conversation

qbit-0
Copy link

@qbit-0 qbit-0 commented Sep 24, 2025

No description provided.


#[cfg(feature = "ext_namespace")]
Namespace {
personal: Option<Vec<NamespaceDescription<'a>>>,
Copy link
Owner

Choose a reason for hiding this comment

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

Question:

Since the ABNF seems to be ...

Namespace = nil / "(" 1*Namespace-Descr ")"

... would it make sense to just use a Vec<NamespaceDescription> without the Option and make it so that an empty vector is encoded as nil?

Currently, None would mean nil but someone could still instantiate Some(vec![]) which... well... should also mean nil? Unclear.

For cases where we want to encode a vector with at least one element, we have Vec1. But instead using Option<Vec1>, Vec is even simpler.

Copy link
Author

Choose a reason for hiding this comment

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

@duesee
Copy link
Owner

duesee commented Oct 1, 2025

With some minor corrections, this looks already good! See b5a3691.

$ cargo run --example=server --features=ext_namespace
# Parsing of IMAP commands

"C:" denotes the client,
"S:" denotes the server, and
".." denotes the continuation of an (incomplete) command, e.g., due to the use of an IMAP literal.

Note: "\n" will be automatically replaced by "\r\n".

--------------------------------------------------------------------------------------------------

Enter IMAP commands (or "exit").

S: * OK ...
C: a namespace
Command {
    tag: Tag("a"),
    body: Namespace,
}
C: 
$ cargo run --example=client --features=ext_namespace
# Parsing of IMAP greeting and responses

"S:" denotes the server.
".." denotes the continuation of an (incomplete) response, e.g., due to the use of an IMAP literal.

Note: "\n" will be automatically replaced by "\r\n".

--------------------------------------------------------------------------------------------------

Enter intial IMAP greeting followed by IMAP responses (or "exit").

S: * OK ...
Greeting {
    kind: Ok,
    code: None,
    text: Text("..."),
}
S: * NAMESPACE (("INBOX." ".")) NIL NIL 
Data(
    Namespace {
        personal: [
            Namespace {
                prefix: String(
                    Quoted(
                        Quoted("INBOX."),
                    ),
                ),
                delimiter: Some(
                    QuotedChar(
                        '.',
                    ),
                ),
                extensions: [],
            },
        ],
        other: [],
        shared: [],
    },
)
S: * NAMESPACE (("" "/")) (("Other Users/" "/")) NIL
Data(
    Namespace {
        personal: [
            Namespace {
                prefix: String(
                    Quoted(
                        Quoted(""),
                    ),
                ),
                delimiter: Some(
                    QuotedChar(
                        '/',
                    ),
                ),
                extensions: [],
            },
        ],
        other: [
            Namespace {
                prefix: String(
                    Quoted(
                        Quoted("Other Users/"),
                    ),
                ),
                delimiter: Some(
                    QuotedChar(
                        '/',
                    ),
                ),
                extensions: [],
            },
        ],
        shared: [],
    },
)
S: 

@duesee
Copy link
Owner

duesee commented Oct 5, 2025

Could you run cargo +nightly fmt? I feel that this PR is almost ready to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants